about summary refs log tree commit diff
path: root/tests/lang
AgeCommit message (Collapse)AuthorFilesLines
2018-04-29 add tests for builtins.addTim Sears2-0/+9
2018-04-23 Merge branch 'pos-crash-fix' of git://github.com/dezgeg/nixShea Levy2-0/+2
2018-04-23 Merge branch 'add-test-eval-okay-nested-with' of ↵Shea Levy2-0/+4
git://github.com/ryantrinkle/nix
2018-04-06 Add missing eval-okay-regex-split.exp test fileDoug Beardsley1-0/+1
2018-04-03 libexpr: Make unsafeGetAttrPos not crash on noPosTuomas Tynkkynen2-0/+2
Currently e.g. `builtins.unsafeGetAttrPos "abort" builtins` will eventually segfault because pos->file is an unset Symbol. Found by afl-fuzz.
2018-03-30 Add test eval-okay-nested-withRyan Trinkle2-0/+4
2018-03-02 libexpr: Recognize newline in more places in lexerTuomas Tynkkynen4-0/+6
Flex's regexes have an annoying feature: the dot matches everything except a newline. This causes problems for expressions like: "${0}\ " where the backslash-newline combination matches this rule instead of the intended one mentioned in the comment: <STRING>\$|\\|\$\\ { /* This can only occur when we reach EOF, otherwise the above (...|\$[^\{\"\\]|\\.|\$\\.)+ would have triggered. This is technically invalid, but we leave the problem to the parser who fails with exact location. */ return STR; } However, the parser actually accepts the resulting token sequence ('"' DOLLAR_CURLY 0 '}' STR '"'), which is a problem because the lexer rule didn't assign anything to yylval. Ultimately this leads to a crash when dereferencing a NULL pointer in ExprConcatStrings::bindVars(). The fix does change the syntax of the language in some corner cases but I think it's only turning previously invalid (or crashing) syntax to valid syntax. E.g. "a\ b" and ''a''\ b'' were previously syntax errors but now both result in "a\nb". Found by afl-fuzz.
2018-02-26 libexpr: Fix prim_replaceStrings() to work on an empty source stringTuomas Tynkkynen2-1/+4
Otherwise, running e.g. nix-instantiate --eval -E --strict 'builtins.replaceStrings [""] ["X"] "abc"' would just hang in an infinite loop. Found by afl-fuzz. First attempt of this was reverted in e2d71bd1862cdda because it caused another infinite loop, which is fixed now and a test added.
2018-02-21 Revert "libexpr: Fix prim_replaceStrings() to work on an empty source string"Eelco Dolstra2-3/+1
This reverts commit 4ea9707591beceacf9988b3c185faf50da238403. It causes an infinite loop in Nixpkgs evaluation, e.g. "nix-instantiate -A hello" hung. PR #1886.
2018-02-19 libexpr: Fix prim_replaceStrings() to work on an empty source stringTuomas Tynkkynen2-1/+3
Otherwise, running e.g. nix-instantiate --eval -E --strict 'builtins.replaceStrings [""] ["X"] "abc"' would just hang in an infinite loop. Found by afl-fuzz.
2018-02-14 Add splitVersion primop.Shea Levy2-0/+2
Fixes #1868.
2018-02-07 builtins.path test: Don't rely on shlevy's XDG_RUNTIME_DIRShea Levy1-1/+0
2018-02-06 Add path primop.Shea Levy3-0/+9
builtins.path allows specifying the name of a path (which makes paths with store-illegal names now addable), allows adding paths with flat instead of recursive hashes, allows specifying a filter (so is a generalization of filterSource), and allows specifying an expected hash (enabling safe path adding in pure mode).
2017-11-14 Revert "Don't parse "x:x" as a URI"Eelco Dolstra2-3/+2
This reverts commit f90f660b243866b8860eeb24cc4a345d32cc7ce7. This broke Hydra's release.nix, which contained preCheck = ''export LOGNAME=${LOGNAME:-foo}'';
2017-10-30 Don't parse "x:x" as a URIEelco Dolstra2-2/+3
URIs now have to contain "://" or start with "channel:".
2017-08-15 Add builtins.string function.Nicolas B. Pierron1-0/+48
The function 'builtins.split' takes a POSIX extended regular expression and an arbitrary string. It returns a list of non-matching substring interleaved by lists of matched groups of the regular expression. ```nix with builtins; assert split "(a)b" "abc" == [ "" [ "a" ] "c" ]; assert split "([ac])" "abc" == [ "" [ "a" ] "b" [ "c" ] "" ]; assert split "(a)|(c)" "abc" == [ "" [ "a" null ] "b" [ null "c" ] "" ]; assert split "([[:upper:]]+)" " FOO " == [ " " [ "FOO" ] " " ]; ```
2017-07-18 Update mailing list.Graham Christensen1-1/+1
2017-05-17 Document that builtins.match takes a POSIX extended REEelco Dolstra1-0/+3
2017-05-01 Fix lexer to support `$'` in multiline strings.Guillaume Maudoux2-2/+10
2016-11-27 Improve error message on trailing path slashesGuillaume Maudoux1-0/+6
2016-11-13 Fix comments parsingGuillaume Maudoux2-0/+60
Fixed the parsing of multiline strings ending with an even number of stars, like /** this **/. Added test cases for comments.
2016-08-29 Add builtin function "partition"Eelco Dolstra2-0/+6
The implementation of "partition" in Nixpkgs is O(n^2) (because of the use of ++), and for some reason was causing stack overflows in multi-threaded evaluation (not sure why). This reduces "nix-env -qa --drv-path" runtime by 0.197s and memory usage by 298 MiB (in non-Boehm mode).
2016-02-15 Fix broken number parsing in fromJSONEelco Dolstra1-1/+1
The call to tmp_number.append had its arguments mixed up. Also, JSON does not allow a trailing "," after array/object members.
2016-02-15 Fix test broken by #762Eelco Dolstra1-1/+1
2016-02-12 Merge pull request #762 from ctheune/ctheune-floatsEelco Dolstra7-3/+23
Implement floats
2016-02-01 Remove tests/lexer.shEelco Dolstra1-0/+2
"tests/lang.sh" can handle this.
2016-01-06 Adapt tests to show that floats work properly.Christian Theune7-3/+23
2015-11-04 Support SHA-512 hashesEelco Dolstra2-5/+2
Fixes #679. Note: on x86_64, SHA-512 is considerably faster than SHA-256 (198 MB/s versus 131 MB/s).
2015-07-28 Add sort primopEelco Dolstra2-0/+9
2015-07-28 Add primop genListEelco Dolstra1-3/+3
This can be used to implement functions like ‘imap’ (or for that matter, ‘map’) without the quadratic complexity incurred by calling ‘++’ repeatedly.
2015-07-24 Add replaceStrings primopEelco Dolstra2-0/+9
This is a generalisation of replaceChars in Nixpkgs.
2015-07-24 Add concatStringsSep as a primopEelco Dolstra2-0/+9
This fixes the quadratic behaviour of concatStrings/concatStringsSep in Nixpkgs.
2015-07-23 Add primops all and anyEelco Dolstra2-0/+12
These are used thousands of times during NixOS evaluation, so it's useful to speed them up.
2015-07-23 Add foldl' primopEelco Dolstra1-1/+1
2015-07-03 Fix the parsing of "$"'s in strings.Guillaume Maudoux2-1/+3
2015-01-29 Merge remote-tracking branch 'shlevy/baseNameOf-no-copy'Shea Levy1-1/+1
baseNameOf: Don't copy paths to the store first
2014-11-25 Add a primop for regular expression pattern matchingEelco Dolstra2-0/+27
The function ‘builtins.match’ takes a POSIX extended regular expression and an arbitrary string. It returns ‘null’ if the string does not match the regular expression. Otherwise, it returns a list containing substring matches corresponding to parenthesis groups in the regex. The regex must match the entire string (i.e. there is an implied "^<pat>$" around the regex). For example: match "foo" "foobar" => null match "foo" "foo" => [] match "f(o+)(.*)" "foooobar" => ["oooo" "bar"] match "(.*/)?([^/]*)" "/dir/file.nix" => ["/dir/" "file.nix"] match "(.*/)?([^/]*)" "file.nix" => [null "file.nix"] The following example finds all regular files with extension .nix or .patch underneath the current directory: let findFiles = pat: dir: concatLists (mapAttrsToList (name: type: if type == "directory" then findFiles pat (dir + "/" + name) else if type == "regular" && match pat name != null then [(dir + "/" + name)] else []) (readDir dir)); in findFiles ".*\\.(nix|patch)" (toString ./.)
2014-11-15 Add functors (callable attribute sets).Shea Levy2-0/+2
With this, attribute sets with a `__functor` attribute can be applied just like normal functions. This can be used to attach arbitrary metadata to a function without callers needing to treat it specially.
2014-10-18 Fix context testShea Levy1-1/+1
2014-10-04 Add primop ‘catAttrs’Eelco Dolstra2-0/+2
2014-10-04 Add primop ‘attrValues’Eelco Dolstra1-1/+1
2014-10-03 Add test for readDir primopShea Levy4-0/+2
2014-09-22 Add ‘deepSeq’ primopEelco Dolstra3-0/+3
Note that unlike ‘lib.deepSeq’ in Nixpkgs, this handles cycles.
2014-09-22 Add ‘seq’ primopEelco Dolstra3-0/+3
2014-07-30 Rename nixPath to __nixPathEelco Dolstra1-4/+4
The name ‘nixPath’ breaks existing code.
2014-07-04 Add builtin function ‘fromJSON’Eelco Dolstra2-0/+33
Fixes #294.
2014-06-10 == operator: Ignore string contextEelco Dolstra1-1/+1
There really is no case I can think of where taking the context into account is useful. Mostly it's just very inconvenient.
2014-05-29 Fix testEelco Dolstra2-2/+2
2014-05-26 Make the Nix search path declarativeEelco Dolstra2-1/+2
Nix search path lookups like <nixpkgs> are now desugared to ‘findFile nixPath <nixpkgs>’, where ‘findFile’ is a new primop. Thus you can override the search path simply by saying let nixPath = [ { prefix = "nixpkgs"; path = "/my-nixpkgs"; } ]; in ... <nixpkgs> ... In conjunction with ‘scopedImport’ (commit c273c15cb13bb86420dda1e5341a4e19517532b5), the Nix search path can be propagated across imports, e.g. let overrides = { nixPath = [ ... ] ++ builtins.nixPath; import = fn: scopedImport overrides fn; scopedImport = attrs: fn: scopedImport (overrides // attrs) fn; builtins = builtins // overrides; }; in scopedImport overrides ./nixos
2014-05-26 Ensure that -I flags get included in nixPathEelco Dolstra1-1/+1
Also fixes #261.