aboutsummaryrefslogtreecommitdiff
path: root/tests/lang
AgeCommit message (Collapse)Author
2020-09-14Escape `${` in strings when printing Nix expressionsregnat
Otherwise the result of the printing can't be parsed back correctly by Nix (because the unescaped `${` will be parsed as the begining of an anti-quotation). Fix #3989
2020-04-02Make function arguments retain position infoSilvan Mosberger
This allows querying the location of function arguments. E.g. builtins.unsafeGetAttrPos "x" (builtins.functionArgs ({ x }: null)) => { column = 57; file = "/home/infinisil/src/nix/inst/test.nix"; line = 1; }
2020-03-11Move some corepkgs into the nix binaryEelco Dolstra
2020-03-04Add test for foldl'Eelco Dolstra
2020-01-07Add support for \u escape in fromJSONNikola Knezevic
As fromTOML supports \u and \U escapes, bring fromJSON on par. As JSON defaults to UTF-8 encoding (every JSON parser must support UTF-8), this change parses the `\u hex hex hex hex` sequence (\u followed by 4 hexadecimal digits) into an UTF-8 representation. Add a test to verify correct parsing, using all escape sequences from json.org.
2019-11-25Add testcase for attrset using __overrides and dynamic attrsPuck Meerburg
2019-10-27Merge branch 'tojson-tostring-fix' of https://github.com/mayflower/nixEelco Dolstra
2019-10-27builtins.toJSON: fix __toString usageRobin Gloster
2019-06-24Fix abort in fromTOMLEelco Dolstra
Fixes #2969.
2019-06-24Add more fromTOML testsEelco Dolstra
2019-05-29Enable more fromTOML testsEelco Dolstra
cpptoml now parses almost all examples from the spec.
2019-05-29Fix eval-okay-fromTOML testEelco Dolstra
Turns out we were mis-parsing single-quoted attributes, e.g. 'key2'.
2019-05-28Merge branch 'attrPaths' of https://github.com/NinjaTrappeur/nixEelco Dolstra
2019-05-08fix hashfile test that wasn't failing due to eval lazinessWill Dietz
See: https://github.com/NixOS/nix/commit/7becb1bf1c2ec1544a5374580a97b36273506baf#r33450554
2019-05-03Add builtins.hashFileDaniel Schaefer
For text files it is possible to do it like so: `builtins.hashString "sha256" (builtins.readFile /tmp/a)` but that doesn't work for binary files. With builtins.hashFile any kind of file can be conveniently hashed.
2019-03-27Update eval-okay-types.exp to match #1828Eelco Dolstra
2019-03-24Add isPath primopzimbatm
this is added for completeness' sake since all the other possible `builtins.typeOf` results have a corresponding `builtins.is<Type>`
2019-01-31Add builtins.appendContext.Shea Levy
A partner of builtins.getContext, useful for the same reasons.
2019-01-14Add builtins.getContext.Shea Levy
This can be very helpful when debugging, as well as enabling complex black magic like surgically removing a single dependency from a string's context.
2018-08-19FIx floating point evaluationEelco Dolstra
Fixes #2361.
2018-07-05lib.concatMap and lib.mapAttrs to be builtinsvolth
2018-07-03Add a fromTOML primopEelco Dolstra
This is primarily useful for processing Cargo.lock files.
2018-05-24add docs and testsvolth
2018-05-11Don't return negative numbers from the flex tokenizerEelco Dolstra
Fixes #1374. Closes #2129.
2018-05-02Fix builtins.add testEelco Dolstra
Nix prints the floating point number 4.0 as "4".
2018-05-01nix-lang: Add deep nested mixed attrs test case.Félix Baylac-Jacqué
2018-04-29add tests for builtins.addTim Sears
2018-04-23Merge branch 'pos-crash-fix' of git://github.com/dezgeg/nixShea Levy
2018-04-23Merge branch 'add-test-eval-okay-nested-with' of ↵Shea Levy
git://github.com/ryantrinkle/nix
2018-04-18parser: Allow mixed nested and top-level attrpathsFélix Baylac-Jacqué
Fixes #2077.
2018-04-17nix-lang parser: Add mixed nested attrs tests.Félix Baylac-Jacqué
Part of issue #2077
2018-04-06Add missing eval-okay-regex-split.exp test fileDoug Beardsley
2018-04-03libexpr: Make unsafeGetAttrPos not crash on noPosTuomas Tynkkynen
Currently e.g. `builtins.unsafeGetAttrPos "abort" builtins` will eventually segfault because pos->file is an unset Symbol. Found by afl-fuzz.
2018-03-30Add test eval-okay-nested-withRyan Trinkle
2018-03-02libexpr: Recognize newline in more places in lexerTuomas Tynkkynen
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-26libexpr: Fix prim_replaceStrings() to work on an empty source stringTuomas Tynkkynen
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-21Revert "libexpr: Fix prim_replaceStrings() to work on an empty source string"Eelco Dolstra
This reverts commit 4ea9707591beceacf9988b3c185faf50da238403. It causes an infinite loop in Nixpkgs evaluation, e.g. "nix-instantiate -A hello" hung. PR #1886.
2018-02-19libexpr: Fix prim_replaceStrings() to work on an empty source stringTuomas Tynkkynen
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-14Add splitVersion primop.Shea Levy
Fixes #1868.
2018-02-07builtins.path test: Don't rely on shlevy's XDG_RUNTIME_DIRShea Levy
2018-02-06Add path primop.Shea Levy
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-14Revert "Don't parse "x:x" as a URI"Eelco Dolstra
This reverts commit f90f660b243866b8860eeb24cc4a345d32cc7ce7. This broke Hydra's release.nix, which contained preCheck = ''export LOGNAME=${LOGNAME:-foo}'';
2017-10-30Don't parse "x:x" as a URIEelco Dolstra
URIs now have to contain "://" or start with "channel:".
2017-08-15Add builtins.string function.Nicolas B. Pierron
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-18Update mailing list.Graham Christensen
2017-05-17Document that builtins.match takes a POSIX extended REEelco Dolstra
2017-05-01Fix lexer to support `$'` in multiline strings.Guillaume Maudoux
2016-11-27Improve error message on trailing path slashesGuillaume Maudoux
2016-11-13Fix comments parsingGuillaume Maudoux
Fixed the parsing of multiline strings ending with an even number of stars, like /** this **/. Added test cases for comments.
2016-08-29Add builtin function "partition"Eelco Dolstra
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).