1
0
Fork 0
mirror of https://github.com/emacs-twist/org-babel.git synced 2025-03-05 08:17:05 +00:00
org-babel/test/test.nix

58 lines
1.6 KiB
Nix

# nix-instantiate --eval --strict test/test.nix
with builtins;
let
pkgs = import <nixpkgs> { };
exclude = import ../nix/excludeOrgSubtreesOnHeadlines.nix;
select = import ../nix/selectHeadlines.nix;
matchOrgTag = import ../nix/matchOrgTag.nix;
matchOrgHeadline = import ../nix/matchOrgHeadline.nix;
dropUntil = import ../nix/dropUntil.nix;
tangleOrgBabel = import ../nix/tangleOrgBabel.nix;
lines = filter (s: isString s && s != "") (split "\n" (readFile ./test.org));
in
pkgs.lib.runTests {
testTagPredicate = {
expr = head (exclude (matchOrgTag "ARCHIVE") lines);
expected = "* Good morning";
};
testHeadlinePredicate = {
expr = head (exclude (matchOrgHeadline "Archived entry") lines);
expected = "* Good morning";
};
testSubtree = {
expr = head (dropUntil (s: s == "Hello!") (exclude (matchOrgTag "irregular") lines));
expected = "* Get to work";
};
testTagPredicate2 = {
expr = pkgs.lib.last (exclude (matchOrgTag "optional") lines);
expected = "It was a good day!";
};
testSelect1 = {
expr = pkgs.lib.last (select (matchOrgTag "irregular") lines);
expected = "Why did he come to the office in the first place?";
};
testSelect2 = {
expr = pkgs.lib.last (select (matchOrgTag "optional") lines);
expected = "/Zaijian/ means goodbye in Mandarin Chinese.";
};
testTangleOrgBabel = {
expr = pkgs.lib.pipe (tangleOrgBabel { } (readFile ./testTangle.org)) [
(split "\n")
(filter isString)
];
expected = [
"Default"
"Alternative language name"
"Upper case"
":tangle yes"
"Extra spaces around params"
];
};
}