feat(tvix/eval): expect not-yet-passing tests to fail
It is helpful to be able to use the test suite as a regression test: make a change to the compiler/vm, re-run the tests, and if there are any failures you know it's your fault. Right now we can't do that, because the expected-to-fail tests are mixed in with the expected-to-pass tests. So we can't use them as a regression test. Change-Id: Ied606882b9835a7effd7e75bfcf3e5f827e0a2c8 Signed-off-by: Adam Joseph <adam@westernsemico.com> Reviewed-on: https://cl.tvl.fyi/c/depot/+/7036 Reviewed-by: tazjin <tazjin@tvl.su> Tested-by: BuildkiteCI
This commit is contained in:
parent
2bc38ce7dc
commit
f991ff9294
74 changed files with 49 additions and 14 deletions
|
|
@ -0,0 +1,4 @@
|
|||
# This must fail to evaluate, since ./fnord doesn't exist. If it did
|
||||
# exist, it would produce "/nix/store/<hash>-fnord/xyzzy" (with an
|
||||
# appropriate context).
|
||||
"${./fnord}/xyzzy"
|
||||
|
|
@ -0,0 +1 @@
|
|||
"${./fnord}"
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
let {
|
||||
|
||||
x = "a";
|
||||
y = "b";
|
||||
|
||||
f = {x ? y, y ? x}: x + y;
|
||||
|
||||
body = f {};
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
({x, z}: x + z) {x = "foo"; y = "bla"; z = "bar";}
|
||||
|
|
@ -0,0 +1 @@
|
|||
{ __overrides = { bar = "qux"; }; bar = "qux"; foo = "bar"; }
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
rec {
|
||||
"${"foo"}" = "bar";
|
||||
__overrides = { bar = "qux"; };
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
"xyzzy!xyzzy!foobar"
|
||||
|
|
@ -0,0 +1 @@
|
|||
--arg lib import(nix_tests/lib.nix) --argstr xyzzy xyzzy! -A result
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
let
|
||||
|
||||
foobar = "foobar";
|
||||
|
||||
in
|
||||
|
||||
{ xyzzy2 ? xyzzy # mutually recursive args
|
||||
, xyzzy ? "blaat" # will be overridden by --argstr
|
||||
, fb ? foobar
|
||||
, lib # will be set by --arg
|
||||
}:
|
||||
|
||||
{
|
||||
result = lib.concat [xyzzy xyzzy2 fb];
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
/foo
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
assert builtins ? currentSystem;
|
||||
assert !builtins ? __currentSystem;
|
||||
|
||||
let {
|
||||
|
||||
x = if builtins ? dirOf then builtins.dirOf /foo/bar else "";
|
||||
|
||||
y = if builtins ? fnord then builtins.fnord "foo" else "";
|
||||
|
||||
body = x + y;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,343 @@
|
|||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<expr>
|
||||
<list>
|
||||
<attrs>
|
||||
<attr name="foo">
|
||||
<bool value="true" />
|
||||
</attr>
|
||||
<attr name="key">
|
||||
<int value="-13" />
|
||||
</attr>
|
||||
</attrs>
|
||||
<attrs>
|
||||
<attr name="foo">
|
||||
<bool value="true" />
|
||||
</attr>
|
||||
<attr name="key">
|
||||
<int value="-12" />
|
||||
</attr>
|
||||
</attrs>
|
||||
<attrs>
|
||||
<attr name="foo">
|
||||
<bool value="true" />
|
||||
</attr>
|
||||
<attr name="key">
|
||||
<int value="-11" />
|
||||
</attr>
|
||||
</attrs>
|
||||
<attrs>
|
||||
<attr name="foo">
|
||||
<bool value="true" />
|
||||
</attr>
|
||||
<attr name="key">
|
||||
<int value="-9" />
|
||||
</attr>
|
||||
</attrs>
|
||||
<attrs>
|
||||
<attr name="foo">
|
||||
<bool value="true" />
|
||||
</attr>
|
||||
<attr name="key">
|
||||
<int value="-8" />
|
||||
</attr>
|
||||
</attrs>
|
||||
<attrs>
|
||||
<attr name="foo">
|
||||
<bool value="true" />
|
||||
</attr>
|
||||
<attr name="key">
|
||||
<int value="-7" />
|
||||
</attr>
|
||||
</attrs>
|
||||
<attrs>
|
||||
<attr name="foo">
|
||||
<bool value="true" />
|
||||
</attr>
|
||||
<attr name="key">
|
||||
<int value="-5" />
|
||||
</attr>
|
||||
</attrs>
|
||||
<attrs>
|
||||
<attr name="foo">
|
||||
<bool value="true" />
|
||||
</attr>
|
||||
<attr name="key">
|
||||
<int value="-4" />
|
||||
</attr>
|
||||
</attrs>
|
||||
<attrs>
|
||||
<attr name="foo">
|
||||
<bool value="true" />
|
||||
</attr>
|
||||
<attr name="key">
|
||||
<int value="-3" />
|
||||
</attr>
|
||||
</attrs>
|
||||
<attrs>
|
||||
<attr name="key">
|
||||
<int value="-1" />
|
||||
</attr>
|
||||
</attrs>
|
||||
<attrs>
|
||||
<attr name="foo">
|
||||
<bool value="true" />
|
||||
</attr>
|
||||
<attr name="key">
|
||||
<int value="0" />
|
||||
</attr>
|
||||
</attrs>
|
||||
<attrs>
|
||||
<attr name="foo">
|
||||
<bool value="true" />
|
||||
</attr>
|
||||
<attr name="key">
|
||||
<int value="1" />
|
||||
</attr>
|
||||
</attrs>
|
||||
<attrs>
|
||||
<attr name="foo">
|
||||
<bool value="true" />
|
||||
</attr>
|
||||
<attr name="key">
|
||||
<int value="2" />
|
||||
</attr>
|
||||
</attrs>
|
||||
<attrs>
|
||||
<attr name="foo">
|
||||
<bool value="true" />
|
||||
</attr>
|
||||
<attr name="key">
|
||||
<int value="4" />
|
||||
</attr>
|
||||
</attrs>
|
||||
<attrs>
|
||||
<attr name="foo">
|
||||
<bool value="true" />
|
||||
</attr>
|
||||
<attr name="key">
|
||||
<int value="5" />
|
||||
</attr>
|
||||
</attrs>
|
||||
<attrs>
|
||||
<attr name="foo">
|
||||
<bool value="true" />
|
||||
</attr>
|
||||
<attr name="key">
|
||||
<int value="6" />
|
||||
</attr>
|
||||
</attrs>
|
||||
<attrs>
|
||||
<attr name="key">
|
||||
<int value="8" />
|
||||
</attr>
|
||||
</attrs>
|
||||
<attrs>
|
||||
<attr name="foo">
|
||||
<bool value="true" />
|
||||
</attr>
|
||||
<attr name="key">
|
||||
<int value="9" />
|
||||
</attr>
|
||||
</attrs>
|
||||
<attrs>
|
||||
<attr name="foo">
|
||||
<bool value="true" />
|
||||
</attr>
|
||||
<attr name="key">
|
||||
<int value="10" />
|
||||
</attr>
|
||||
</attrs>
|
||||
<attrs>
|
||||
<attr name="foo">
|
||||
<bool value="true" />
|
||||
</attr>
|
||||
<attr name="key">
|
||||
<int value="13" />
|
||||
</attr>
|
||||
</attrs>
|
||||
<attrs>
|
||||
<attr name="foo">
|
||||
<bool value="true" />
|
||||
</attr>
|
||||
<attr name="key">
|
||||
<int value="14" />
|
||||
</attr>
|
||||
</attrs>
|
||||
<attrs>
|
||||
<attr name="foo">
|
||||
<bool value="true" />
|
||||
</attr>
|
||||
<attr name="key">
|
||||
<int value="15" />
|
||||
</attr>
|
||||
</attrs>
|
||||
<attrs>
|
||||
<attr name="key">
|
||||
<int value="17" />
|
||||
</attr>
|
||||
</attrs>
|
||||
<attrs>
|
||||
<attr name="foo">
|
||||
<bool value="true" />
|
||||
</attr>
|
||||
<attr name="key">
|
||||
<int value="18" />
|
||||
</attr>
|
||||
</attrs>
|
||||
<attrs>
|
||||
<attr name="foo">
|
||||
<bool value="true" />
|
||||
</attr>
|
||||
<attr name="key">
|
||||
<int value="19" />
|
||||
</attr>
|
||||
</attrs>
|
||||
<attrs>
|
||||
<attr name="foo">
|
||||
<bool value="true" />
|
||||
</attr>
|
||||
<attr name="key">
|
||||
<int value="22" />
|
||||
</attr>
|
||||
</attrs>
|
||||
<attrs>
|
||||
<attr name="foo">
|
||||
<bool value="true" />
|
||||
</attr>
|
||||
<attr name="key">
|
||||
<int value="23" />
|
||||
</attr>
|
||||
</attrs>
|
||||
<attrs>
|
||||
<attr name="key">
|
||||
<int value="26" />
|
||||
</attr>
|
||||
</attrs>
|
||||
<attrs>
|
||||
<attr name="foo">
|
||||
<bool value="true" />
|
||||
</attr>
|
||||
<attr name="key">
|
||||
<int value="27" />
|
||||
</attr>
|
||||
</attrs>
|
||||
<attrs>
|
||||
<attr name="foo">
|
||||
<bool value="true" />
|
||||
</attr>
|
||||
<attr name="key">
|
||||
<int value="28" />
|
||||
</attr>
|
||||
</attrs>
|
||||
<attrs>
|
||||
<attr name="foo">
|
||||
<bool value="true" />
|
||||
</attr>
|
||||
<attr name="key">
|
||||
<int value="31" />
|
||||
</attr>
|
||||
</attrs>
|
||||
<attrs>
|
||||
<attr name="foo">
|
||||
<bool value="true" />
|
||||
</attr>
|
||||
<attr name="key">
|
||||
<int value="32" />
|
||||
</attr>
|
||||
</attrs>
|
||||
<attrs>
|
||||
<attr name="key">
|
||||
<int value="35" />
|
||||
</attr>
|
||||
</attrs>
|
||||
<attrs>
|
||||
<attr name="foo">
|
||||
<bool value="true" />
|
||||
</attr>
|
||||
<attr name="key">
|
||||
<int value="36" />
|
||||
</attr>
|
||||
</attrs>
|
||||
<attrs>
|
||||
<attr name="foo">
|
||||
<bool value="true" />
|
||||
</attr>
|
||||
<attr name="key">
|
||||
<int value="40" />
|
||||
</attr>
|
||||
</attrs>
|
||||
<attrs>
|
||||
<attr name="foo">
|
||||
<bool value="true" />
|
||||
</attr>
|
||||
<attr name="key">
|
||||
<int value="41" />
|
||||
</attr>
|
||||
</attrs>
|
||||
<attrs>
|
||||
<attr name="key">
|
||||
<int value="44" />
|
||||
</attr>
|
||||
</attrs>
|
||||
<attrs>
|
||||
<attr name="foo">
|
||||
<bool value="true" />
|
||||
</attr>
|
||||
<attr name="key">
|
||||
<int value="45" />
|
||||
</attr>
|
||||
</attrs>
|
||||
<attrs>
|
||||
<attr name="foo">
|
||||
<bool value="true" />
|
||||
</attr>
|
||||
<attr name="key">
|
||||
<int value="49" />
|
||||
</attr>
|
||||
</attrs>
|
||||
<attrs>
|
||||
<attr name="key">
|
||||
<int value="53" />
|
||||
</attr>
|
||||
</attrs>
|
||||
<attrs>
|
||||
<attr name="foo">
|
||||
<bool value="true" />
|
||||
</attr>
|
||||
<attr name="key">
|
||||
<int value="54" />
|
||||
</attr>
|
||||
</attrs>
|
||||
<attrs>
|
||||
<attr name="foo">
|
||||
<bool value="true" />
|
||||
</attr>
|
||||
<attr name="key">
|
||||
<int value="58" />
|
||||
</attr>
|
||||
</attrs>
|
||||
<attrs>
|
||||
<attr name="key">
|
||||
<int value="62" />
|
||||
</attr>
|
||||
</attrs>
|
||||
<attrs>
|
||||
<attr name="foo">
|
||||
<bool value="true" />
|
||||
</attr>
|
||||
<attr name="key">
|
||||
<int value="67" />
|
||||
</attr>
|
||||
</attrs>
|
||||
<attrs>
|
||||
<attr name="key">
|
||||
<int value="71" />
|
||||
</attr>
|
||||
</attrs>
|
||||
<attrs>
|
||||
<attr name="key">
|
||||
<int value="80" />
|
||||
</attr>
|
||||
</attrs>
|
||||
</list>
|
||||
</expr>
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
let
|
||||
|
||||
closure = builtins.genericClosure {
|
||||
startSet = [{key = 80;}];
|
||||
operator = {key, foo ? false}:
|
||||
if builtins.lessThan key 0
|
||||
then []
|
||||
else [{key = builtins.sub key 9;} {key = builtins.sub key 13; foo = true;}];
|
||||
};
|
||||
|
||||
sort = (import ./lib.nix).sortBy (a: b: builtins.lessThan a.key b.key);
|
||||
|
||||
in sort closure
|
||||
|
|
@ -0,0 +1 @@
|
|||
true
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
let
|
||||
drv = derivation {
|
||||
name = "fail";
|
||||
builder = "/bin/false";
|
||||
system = "x86_64-linux";
|
||||
outputs = [ "out" "foo" ];
|
||||
};
|
||||
|
||||
path = "${./eval-okay-context-introspection.nix}";
|
||||
|
||||
desired-context = {
|
||||
"${builtins.unsafeDiscardStringContext path}" = {
|
||||
path = true;
|
||||
};
|
||||
"${builtins.unsafeDiscardStringContext drv.drvPath}" = {
|
||||
outputs = [ "foo" "out" ];
|
||||
allOutputs = true;
|
||||
};
|
||||
};
|
||||
|
||||
legit-context = builtins.getContext "${path}${drv.outPath}${drv.foo.outPath}${drv.drvPath}";
|
||||
|
||||
constructed-context = builtins.getContext (builtins.appendContext "" desired-context);
|
||||
in legit-context == constructed-context
|
||||
|
|
@ -0,0 +1 @@
|
|||
"foo eval-okay-context.nix bar"
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
let s = "foo ${builtins.substring 33 100 (baseNameOf "${./eval-okay-context.nix}")} bar";
|
||||
in
|
||||
if s != "foo eval-okay-context.nix bar"
|
||||
then abort "context not discarded"
|
||||
else builtins.unsafeDiscardStringContext s
|
||||
|
||||
|
|
@ -0,0 +1 @@
|
|||
[ 3 7 4 9 ]
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
# Bla
|
||||
let
|
||||
x = __curPos;
|
||||
y = __curPos;
|
||||
in [ x.line x.column y.line y.column ]
|
||||
|
|
@ -0,0 +1 @@
|
|||
456
|
||||
|
|
@ -0,0 +1 @@
|
|||
builtins.deepSeq (let as = { x = 123; y = as; }; in as) 456
|
||||
|
|
@ -0,0 +1 @@
|
|||
"b-overridden"
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
let
|
||||
pkgs_ = with pkgs; {
|
||||
a = derivation {
|
||||
name = "a";
|
||||
system = builtins.currentSystem;
|
||||
builder = "/bin/sh";
|
||||
args = [ "-c" "touch $out" ];
|
||||
inherit b;
|
||||
};
|
||||
|
||||
inherit b;
|
||||
};
|
||||
|
||||
packageOverrides = p: {
|
||||
b = derivation {
|
||||
name = "b-overridden";
|
||||
system = builtins.currentSystem;
|
||||
builder = "/bin/sh";
|
||||
args = [ "-c" "touch $out" ];
|
||||
};
|
||||
};
|
||||
|
||||
pkgs = pkgs_ // (packageOverrides pkgs_);
|
||||
in pkgs.a.b.name
|
||||
|
|
@ -0,0 +1 @@
|
|||
"b-overridden b-overridden a"
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
let
|
||||
|
||||
pkgs_ = with pkgs; {
|
||||
a = derivation {
|
||||
name = "a";
|
||||
system = builtins.currentSystem;
|
||||
builder = "/bin/sh";
|
||||
args = [ "-c" "touch $out" ];
|
||||
inherit b;
|
||||
};
|
||||
|
||||
b = derivation {
|
||||
name = "b";
|
||||
system = builtins.currentSystem;
|
||||
builder = "/bin/sh";
|
||||
args = [ "-c" "touch $out" ];
|
||||
inherit a;
|
||||
};
|
||||
|
||||
c = b;
|
||||
};
|
||||
|
||||
packageOverrides = pkgs: with pkgs; {
|
||||
b = derivation (b.drvAttrs // { name = "${b.name}-overridden"; });
|
||||
};
|
||||
|
||||
pkgs = pkgs_ // (packageOverrides pkgs_);
|
||||
|
||||
in "${pkgs.a.b.name} ${pkgs.c.name} ${pkgs.b.a.name}"
|
||||
|
|
@ -0,0 +1 @@
|
|||
[ true true true false ]
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
let
|
||||
|
||||
drvA1 = derivation { name = "a"; builder = "/foo"; system = "i686-linux"; };
|
||||
drvA2 = derivation { name = "a"; builder = "/foo"; system = "i686-linux"; };
|
||||
drvA3 = derivation { name = "a"; builder = "/foo"; system = "i686-linux"; } // { dummy = 1; };
|
||||
|
||||
drvC1 = derivation { name = "c"; builder = "/foo"; system = "i686-linux"; };
|
||||
drvC2 = derivation { name = "c"; builder = "/bar"; system = "i686-linux"; };
|
||||
|
||||
in [ (drvA1 == drvA1) (drvA1 == drvA2) (drvA1 == drvA3) (drvC1 == drvC2) ]
|
||||
|
|
@ -0,0 +1 @@
|
|||
Bool(True)
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
["foobar" (rec {x = 1; y = x;})]
|
||||
==
|
||||
[("foo" + "bar") ({x = 1; y = 1;})]
|
||||
|
|
@ -0,0 +1 @@
|
|||
[ { clients = { data = [ [ "gamma" "delta" ] [ 1 2 ] ]; hosts = [ "alpha" "omega" ]; }; database = { connection_max = 5000; enabled = true; ports = [ 8001 8001 8002 ]; server = "192.168.1.1"; }; owner = { name = "Tom Preston-Werner"; }; servers = { alpha = { dc = "eqdc10"; ip = "10.0.0.1"; }; beta = { dc = "eqdc10"; ip = "10.0.0.2"; }; }; title = "TOML Example"; } { "1234" = "value"; "127.0.0.1" = "value"; a = { b = { c = { }; }; }; arr1 = [ 1 2 3 ]; arr2 = [ "red" "yellow" "green" ]; arr3 = [ [ 1 2 ] [ 3 4 5 ] ]; arr4 = [ "all" "strings" "are the same" "type" ]; arr5 = [ [ 1 2 ] [ "a" "b" "c" ] ]; arr7 = [ 1 2 3 ]; arr8 = [ 1 2 ]; bare-key = "value"; bare_key = "value"; bin1 = 214; bool1 = true; bool2 = false; "character encoding" = "value"; d = { e = { f = { }; }; }; dog = { "tater.man" = { type = { name = "pug"; }; }; }; flt1 = 1; flt2 = 3.1415; flt3 = -0.01; flt4 = 5e+22; flt5 = 1e+06; flt6 = -0.02; flt7 = 6.626e-34; flt8 = 9.22462e+06; fruit = [ { name = "apple"; physical = { color = "red"; shape = "round"; }; variety = [ { name = "red delicious"; } { name = "granny smith"; } ]; } { name = "banana"; variety = [ { name = "plantain"; } ]; } ]; g = { h = { i = { }; }; }; hex1 = 3735928559; hex2 = 3735928559; hex3 = 3735928559; int1 = 99; int2 = 42; int3 = 0; int4 = -17; int5 = 1000; int6 = 5349221; int7 = 12345; j = { "ʞ" = { l = { }; }; }; key = "value"; key2 = "value"; name = "Orange"; oct1 = 342391; oct2 = 493; physical = { color = "orange"; shape = "round"; }; products = [ { name = "Hammer"; sku = 738594937; } { } { color = "gray"; name = "Nail"; sku = 284758393; } ]; "quoted \"value\"" = "value"; site = { "google.com" = true; }; str = "I'm a string. \"You can quote me\". Name\tJosé\nLocation\tSF."; table-1 = { key1 = "some string"; key2 = 123; }; table-2 = { key1 = "another string"; key2 = 456; }; x = { y = { z = { w = { animal = { type = { name = "pug"; }; }; name = { first = "Tom"; last = "Preston-Werner"; }; point = { x = 1; y = 2; }; }; }; }; }; "ʎǝʞ" = "value"; } { metadata = { "checksum aho-corasick 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)" = "d6531d44de723825aa81398a6415283229725a00fa30713812ab9323faa82fc4"; "checksum ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b"; "checksum ansi_term 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "23ac7c30002a5accbf7e8987d0632fa6de155b7c3d39d0067317a391e00a2ef6"; "checksum arrayvec 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)" = "a1e964f9e24d588183fcb43503abda40d288c8657dfc27311516ce2f05675aef"; }; package = [ { dependencies = [ "memchr 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)" ]; name = "aho-corasick"; source = "registry+https://github.com/rust-lang/crates.io-index"; version = "0.6.4"; } { name = "ansi_term"; source = "registry+https://github.com/rust-lang/crates.io-index"; version = "0.9.0"; } { dependencies = [ "libc 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)" "termion 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)" "winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)" ]; name = "atty"; source = "registry+https://github.com/rust-lang/crates.io-index"; version = "0.2.10"; } ]; } { a = [ [ { b = true; } ] ]; c = [ [ { d = true; } ] ]; e = [ [ 123 ] ]; } ]
|
||||
|
|
@ -0,0 +1,208 @@
|
|||
[
|
||||
|
||||
(builtins.fromTOML ''
|
||||
# This is a TOML document.
|
||||
|
||||
title = "TOML Example"
|
||||
|
||||
[owner]
|
||||
name = "Tom Preston-Werner"
|
||||
#dob = 1979-05-27T07:32:00-08:00 # First class dates
|
||||
|
||||
[database]
|
||||
server = "192.168.1.1"
|
||||
ports = [ 8001, 8001, 8002 ]
|
||||
connection_max = 5000
|
||||
enabled = true
|
||||
|
||||
[servers]
|
||||
|
||||
# Indentation (tabs and/or spaces) is allowed but not required
|
||||
[servers.alpha]
|
||||
ip = "10.0.0.1"
|
||||
dc = "eqdc10"
|
||||
|
||||
[servers.beta]
|
||||
ip = "10.0.0.2"
|
||||
dc = "eqdc10"
|
||||
|
||||
[clients]
|
||||
data = [ ["gamma", "delta"], [1, 2] ]
|
||||
|
||||
# Line breaks are OK when inside arrays
|
||||
hosts = [
|
||||
"alpha",
|
||||
"omega"
|
||||
]
|
||||
'')
|
||||
|
||||
(builtins.fromTOML ''
|
||||
key = "value"
|
||||
bare_key = "value"
|
||||
bare-key = "value"
|
||||
1234 = "value"
|
||||
|
||||
"127.0.0.1" = "value"
|
||||
"character encoding" = "value"
|
||||
"ʎǝʞ" = "value"
|
||||
'key2' = "value"
|
||||
'quoted "value"' = "value"
|
||||
|
||||
name = "Orange"
|
||||
|
||||
physical.color = "orange"
|
||||
physical.shape = "round"
|
||||
site."google.com" = true
|
||||
|
||||
# This is legal according to the spec, but cpptoml doesn't handle it.
|
||||
#a.b.c = 1
|
||||
#a.d = 2
|
||||
|
||||
str = "I'm a string. \"You can quote me\". Name\tJos\u00E9\nLocation\tSF."
|
||||
|
||||
int1 = +99
|
||||
int2 = 42
|
||||
int3 = 0
|
||||
int4 = -17
|
||||
int5 = 1_000
|
||||
int6 = 5_349_221
|
||||
int7 = 1_2_3_4_5
|
||||
|
||||
hex1 = 0xDEADBEEF
|
||||
hex2 = 0xdeadbeef
|
||||
hex3 = 0xdead_beef
|
||||
|
||||
oct1 = 0o01234567
|
||||
oct2 = 0o755
|
||||
|
||||
bin1 = 0b11010110
|
||||
|
||||
flt1 = +1.0
|
||||
flt2 = 3.1415
|
||||
flt3 = -0.01
|
||||
flt4 = 5e+22
|
||||
flt5 = 1e6
|
||||
flt6 = -2E-2
|
||||
flt7 = 6.626e-34
|
||||
flt8 = 9_224_617.445_991_228_313
|
||||
|
||||
bool1 = true
|
||||
bool2 = false
|
||||
|
||||
# FIXME: not supported because Nix doesn't have a date/time type.
|
||||
#odt1 = 1979-05-27T07:32:00Z
|
||||
#odt2 = 1979-05-27T00:32:00-07:00
|
||||
#odt3 = 1979-05-27T00:32:00.999999-07:00
|
||||
#odt4 = 1979-05-27 07:32:00Z
|
||||
#ldt1 = 1979-05-27T07:32:00
|
||||
#ldt2 = 1979-05-27T00:32:00.999999
|
||||
#ld1 = 1979-05-27
|
||||
#lt1 = 07:32:00
|
||||
#lt2 = 00:32:00.999999
|
||||
|
||||
arr1 = [ 1, 2, 3 ]
|
||||
arr2 = [ "red", "yellow", "green" ]
|
||||
arr3 = [ [ 1, 2 ], [3, 4, 5] ]
|
||||
arr4 = [ "all", 'strings', """are the same""", ''''type'''']
|
||||
arr5 = [ [ 1, 2 ], ["a", "b", "c"] ]
|
||||
|
||||
arr7 = [
|
||||
1, 2, 3
|
||||
]
|
||||
|
||||
arr8 = [
|
||||
1,
|
||||
2, # this is ok
|
||||
]
|
||||
|
||||
[table-1]
|
||||
key1 = "some string"
|
||||
key2 = 123
|
||||
|
||||
|
||||
[table-2]
|
||||
key1 = "another string"
|
||||
key2 = 456
|
||||
|
||||
[dog."tater.man"]
|
||||
type.name = "pug"
|
||||
|
||||
[a.b.c]
|
||||
[ d.e.f ]
|
||||
[ g . h . i ]
|
||||
[ j . "ʞ" . 'l' ]
|
||||
[x.y.z.w]
|
||||
|
||||
name = { first = "Tom", last = "Preston-Werner" }
|
||||
point = { x = 1, y = 2 }
|
||||
animal = { type.name = "pug" }
|
||||
|
||||
[[products]]
|
||||
name = "Hammer"
|
||||
sku = 738594937
|
||||
|
||||
[[products]]
|
||||
|
||||
[[products]]
|
||||
name = "Nail"
|
||||
sku = 284758393
|
||||
color = "gray"
|
||||
|
||||
[[fruit]]
|
||||
name = "apple"
|
||||
|
||||
[fruit.physical]
|
||||
color = "red"
|
||||
shape = "round"
|
||||
|
||||
[[fruit.variety]]
|
||||
name = "red delicious"
|
||||
|
||||
[[fruit.variety]]
|
||||
name = "granny smith"
|
||||
|
||||
[[fruit]]
|
||||
name = "banana"
|
||||
|
||||
[[fruit.variety]]
|
||||
name = "plantain"
|
||||
'')
|
||||
|
||||
(builtins.fromTOML ''
|
||||
[[package]]
|
||||
name = "aho-corasick"
|
||||
version = "0.6.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"memchr 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ansi_term"
|
||||
version = "0.9.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "atty"
|
||||
version = "0.2.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"libc 0.2.42 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"termion 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"winapi 0.3.5 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[metadata]
|
||||
"checksum aho-corasick 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)" = "d6531d44de723825aa81398a6415283229725a00fa30713812ab9323faa82fc4"
|
||||
"checksum ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b"
|
||||
"checksum ansi_term 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "23ac7c30002a5accbf7e8987d0632fa6de155b7c3d39d0067317a391e00a2ef6"
|
||||
"checksum arrayvec 0.4.7 (registry+https://github.com/rust-lang/crates.io-index)" = "a1e964f9e24d588183fcb43503abda40d288c8657dfc27311516ce2f05675aef"
|
||||
'')
|
||||
|
||||
(builtins.fromTOML ''
|
||||
a = [[{ b = true }]]
|
||||
c = [ [ { d = true } ] ]
|
||||
e = [[123]]
|
||||
'')
|
||||
|
||||
]
|
||||
|
|
@ -0,0 +1 @@
|
|||
true
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
# RFC 7159, section 13.
|
||||
builtins.fromJSON
|
||||
''
|
||||
{
|
||||
"Image": {
|
||||
"Width": 800,
|
||||
"Height": 600,
|
||||
"Title": "View from 15th Floor",
|
||||
"Thumbnail": {
|
||||
"Url": "http://www.example.com/image/481989943",
|
||||
"Height": 125,
|
||||
"Width": 100
|
||||
},
|
||||
"Animated" : false,
|
||||
"IDs": [116, 943, 234, 38793, true ,false,null, -100],
|
||||
"Latitude": 37.7668,
|
||||
"Longitude": -122.3959
|
||||
}
|
||||
}
|
||||
''
|
||||
==
|
||||
{ Image =
|
||||
{ Width = 800;
|
||||
Height = 600;
|
||||
Title = "View from 15th Floor";
|
||||
Thumbnail =
|
||||
{ Url = http://www.example.com/image/481989943;
|
||||
Height = 125;
|
||||
Width = 100;
|
||||
};
|
||||
Animated = false;
|
||||
IDs = [ 116 943 234 38793 true false null (0-100) ];
|
||||
Latitude = 37.7668;
|
||||
Longitude = -122.3959;
|
||||
};
|
||||
}
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<expr>
|
||||
<list>
|
||||
<string value="stdenv" />
|
||||
<string value="fetchurl" />
|
||||
<string value="aterm-stdenv" />
|
||||
<string value="aterm-stdenv2" />
|
||||
<string value="libX11" />
|
||||
<string value="libXv" />
|
||||
<string value="mplayer-stdenv2.libXv-libX11" />
|
||||
<string value="mplayer-stdenv2.libXv-libX11_2" />
|
||||
<string value="nix-stdenv-aterm-stdenv" />
|
||||
<string value="nix-stdenv2-aterm2-stdenv2" />
|
||||
</list>
|
||||
</expr>
|
||||
|
|
@ -0,0 +1,80 @@
|
|||
let
|
||||
|
||||
stdenvFun = { }: { name = "stdenv"; };
|
||||
stdenv2Fun = { }: { name = "stdenv2"; };
|
||||
fetchurlFun = { stdenv }: assert stdenv.name == "stdenv"; { name = "fetchurl"; };
|
||||
atermFun = { stdenv, fetchurl }: { name = "aterm-${stdenv.name}"; };
|
||||
aterm2Fun = { stdenv, fetchurl }: { name = "aterm2-${stdenv.name}"; };
|
||||
nixFun = { stdenv, fetchurl, aterm }: { name = "nix-${stdenv.name}-${aterm.name}"; };
|
||||
|
||||
mplayerFun =
|
||||
{ stdenv, fetchurl, enableX11 ? false, xorg ? null, enableFoo ? true, foo ? null }:
|
||||
assert stdenv.name == "stdenv2";
|
||||
assert enableX11 -> xorg.libXv.name == "libXv";
|
||||
assert enableFoo -> foo != null;
|
||||
{ name = "mplayer-${stdenv.name}.${xorg.libXv.name}-${xorg.libX11.name}"; };
|
||||
|
||||
makeOverridable = f: origArgs: f origArgs //
|
||||
{ override = newArgs:
|
||||
makeOverridable f (origArgs // (if builtins.isFunction newArgs then newArgs origArgs else newArgs));
|
||||
};
|
||||
|
||||
callPackage_ = pkgs: f: args:
|
||||
makeOverridable f ((builtins.intersectAttrs (builtins.functionArgs f) pkgs) // args);
|
||||
|
||||
allPackages =
|
||||
{ overrides ? (pkgs: pkgsPrev: { }) }:
|
||||
let
|
||||
callPackage = callPackage_ pkgs;
|
||||
pkgs = pkgsStd // (overrides pkgs pkgsStd);
|
||||
pkgsStd = {
|
||||
inherit pkgs;
|
||||
stdenv = callPackage stdenvFun { };
|
||||
stdenv2 = callPackage stdenv2Fun { };
|
||||
fetchurl = callPackage fetchurlFun { };
|
||||
aterm = callPackage atermFun { };
|
||||
xorg = callPackage xorgFun { };
|
||||
mplayer = callPackage mplayerFun { stdenv = pkgs.stdenv2; enableFoo = false; };
|
||||
nix = callPackage nixFun { };
|
||||
};
|
||||
in pkgs;
|
||||
|
||||
libX11Fun = { stdenv, fetchurl }: { name = "libX11"; };
|
||||
libX11_2Fun = { stdenv, fetchurl }: { name = "libX11_2"; };
|
||||
libXvFun = { stdenv, fetchurl, libX11 }: { name = "libXv"; };
|
||||
|
||||
xorgFun =
|
||||
{ pkgs }:
|
||||
let callPackage = callPackage_ (pkgs // pkgs.xorg); in
|
||||
{
|
||||
libX11 = callPackage libX11Fun { };
|
||||
libXv = callPackage libXvFun { };
|
||||
};
|
||||
|
||||
in
|
||||
|
||||
let
|
||||
|
||||
pkgs = allPackages { };
|
||||
|
||||
pkgs2 = allPackages {
|
||||
overrides = pkgs: pkgsPrev: {
|
||||
stdenv = pkgs.stdenv2;
|
||||
nix = pkgsPrev.nix.override { aterm = aterm2Fun { inherit (pkgs) stdenv fetchurl; }; };
|
||||
xorg = pkgsPrev.xorg // { libX11 = libX11_2Fun { inherit (pkgs) stdenv fetchurl; }; };
|
||||
};
|
||||
};
|
||||
|
||||
in
|
||||
|
||||
[ pkgs.stdenv.name
|
||||
pkgs.fetchurl.name
|
||||
pkgs.aterm.name
|
||||
pkgs2.aterm.name
|
||||
pkgs.xorg.libX11.name
|
||||
pkgs.xorg.libXv.name
|
||||
pkgs.mplayer.name
|
||||
pkgs2.mplayer.name
|
||||
pkgs.nix.name
|
||||
pkgs2.nix.name
|
||||
]
|
||||
|
|
@ -0,0 +1 @@
|
|||
null
|
||||
|
|
@ -0,0 +1 @@
|
|||
builtins.unsafeGetAttrPos "abort" builtins
|
||||
|
|
@ -0,0 +1 @@
|
|||
{ column = 5; file = "eval-okay-getattrpos.nix"; line = 3; }
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
let
|
||||
as = {
|
||||
foo = "bar";
|
||||
};
|
||||
pos = builtins.unsafeGetAttrPos "foo" as;
|
||||
in { inherit (pos) column line; file = baseNameOf pos.file; }
|
||||
|
|
@ -0,0 +1 @@
|
|||
"foobar"
|
||||
|
|
@ -0,0 +1 @@
|
|||
builtins.getEnv "TEST_VAR" + (if builtins.getEnv "NO_SUCH_VAR" == "" then "bar" else "bla")
|
||||
|
|
@ -0,0 +1 @@
|
|||
[ "d3b07384d113edec49eaa6238ad5ff00" "0f343b0931126a20f133d67c2b018a3b" "f1d2d2f924e986ac86fdf7b36c94bcdf32beec15" "60cacbf3d72e1e7834203da608037b1bf83b40e8" "b5bb9d8014a0f9b1d61e21e796d78dccdf1352f23cd32812f4850b878ae4944c" "5f70bf18a086007016e948b04aed3b82103a36bea41755b6cddfaf10ace3c6ef" "0cf9180a764aba863a67b6d72f0918bc131c6772642cb2dce5a34f0a702f9470ddc2bf125c12198b1995c233c34b4afd346c54a2334c350a948a51b6e8b4e6b6" "8efb4f73c5655351c444eb109230c556d39e2c7624e9c11abc9e3fb4b9b9254218cc5085b454a9698d085cfa92198491f07a723be4574adc70617b73eb0b6461" ]
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
let
|
||||
paths = [ ./data ./binary-data ];
|
||||
in
|
||||
builtins.concatLists (map (hash: map (builtins.hashFile hash) paths) ["md5" "sha1" "sha256" "sha512"])
|
||||
|
|
@ -0,0 +1 @@
|
|||
[ "d41d8cd98f00b204e9800998ecf8427e" "6c69ee7f211c640419d5366cc076ae46" "bb3438fbabd460ea6dbd27d153e2233b" "da39a3ee5e6b4b0d3255bfef95601890afd80709" "cd54e8568c1b37cf1e5badb0779bcbf382212189" "6d12e10b1d331dad210e47fd25d4f260802b7e77" "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" "900a4469df00ccbfd0c145c6d1e4b7953dd0afafadd7534e3a4019e8d38fc663" "ad0387b3bd8652f730ca46d25f9c170af0fd589f42e7f23f5a9e6412d97d7e56" "cf83e1357eefb8bdf1542850d66d8007d620e4050b5715dc83f4a921d36ce9ce47d0d13c5d85f2b0ff8318d2877eec2f63b931bd47417a81a538327af927da3e" "9d0886f8c6b389398a16257bc79780fab9831c7fc11c8ab07fa732cb7b348feade382f92617c9c5305fefba0af02ab5fd39a587d330997ff5bd0db19f7666653" "21644b72aa259e5a588cd3afbafb1d4310f4889680f6c83b9d531596a5a284f34dbebff409d23bcc86aee6bad10c891606f075c6f4755cb536da27db5693f3a7" ]
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
let
|
||||
strings = [ "" "text 1" "text 2" ];
|
||||
in
|
||||
builtins.concatLists (map (hash: map (builtins.hashString hash) strings) ["md5" "sha1" "sha256" "sha512"])
|
||||
|
|
@ -0,0 +1 @@
|
|||
[ 1 2 3 4 5 6 7 8 9 10 ]
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
let
|
||||
|
||||
overrides = {
|
||||
import = fn: scopedImport overrides fn;
|
||||
|
||||
scopedImport = attrs: fn: scopedImport (overrides // attrs) fn;
|
||||
|
||||
builtins = builtins // overrides;
|
||||
} // import ./lib.nix;
|
||||
|
||||
in scopedImport overrides ./imported.nix
|
||||
|
|
@ -0,0 +1 @@
|
|||
{ x = "x-foo"; y = "y-bar"; }
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
with import ./lib.nix;
|
||||
|
||||
builtins.mapAttrs (name: value: name + "-" + value) { x = "foo"; y = "bar"; }
|
||||
|
|
@ -0,0 +1 @@
|
|||
2
|
||||
|
|
@ -0,0 +1,9 @@
|
|||
let
|
||||
|
||||
overrides = { a = 2; };
|
||||
|
||||
in (rec {
|
||||
__overrides = overrides;
|
||||
x = a;
|
||||
a = 1;
|
||||
}).x
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
builtins.path
|
||||
{ path = ./.;
|
||||
filter = path: _: baseNameOf path == "data";
|
||||
recursive = true;
|
||||
sha256 = "1yhm3gwvg5a41yylymgblsclk95fs6jy72w0wv925mmidlhcq4sw";
|
||||
name = "output";
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
true
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
builtins.pathExists (builtins.toPath ./lib.nix)
|
||||
&& builtins.pathExists (builtins.toPath (builtins.toString ./lib.nix))
|
||||
&& !builtins.pathExists (builtins.toPath (builtins.toString ./bla.nix))
|
||||
&& builtins.pathExists ./lib.nix
|
||||
&& !builtins.pathExists ./bla.nix
|
||||
|
|
@ -0,0 +1 @@
|
|||
true
|
||||
|
|
@ -0,0 +1,48 @@
|
|||
with builtins;
|
||||
|
||||
# Non capturing regex returns empty lists
|
||||
assert split "foobar" "foobar" == ["" [] ""];
|
||||
assert split "fo*" "f" == ["" [] ""];
|
||||
assert split "fo+" "f" == ["f"];
|
||||
assert split "fo*" "fo" == ["" [] ""];
|
||||
assert split "fo*" "foo" == ["" [] ""];
|
||||
assert split "fo+" "foo" == ["" [] ""];
|
||||
assert split "fo{1,2}" "foo" == ["" [] ""];
|
||||
assert split "fo{1,2}" "fooo" == ["" [] "o"];
|
||||
assert split "fo*" "foobar" == ["" [] "bar"];
|
||||
|
||||
# Capturing regex returns a list of sub-matches
|
||||
assert split "(fo*)" "f" == ["" ["f"] ""];
|
||||
assert split "(fo+)" "f" == ["f"];
|
||||
assert split "(fo*)" "fo" == ["" ["fo"] ""];
|
||||
assert split "(f)(o*)" "f" == ["" ["f" ""] ""];
|
||||
assert split "(f)(o*)" "foo" == ["" ["f" "oo"] ""];
|
||||
assert split "(fo+)" "foo" == ["" ["foo"] ""];
|
||||
assert split "(fo{1,2})" "foo" == ["" ["foo"] ""];
|
||||
assert split "(fo{1,2})" "fooo" == ["" ["foo"] "o"];
|
||||
assert split "(fo*)" "foobar" == ["" ["foo"] "bar"];
|
||||
|
||||
# Matches are greedy.
|
||||
assert split "(o+)" "oooofoooo" == ["" ["oooo"] "f" ["oooo"] ""];
|
||||
|
||||
# Matches multiple times.
|
||||
assert split "(b)" "foobarbaz" == ["foo" ["b"] "ar" ["b"] "az"];
|
||||
|
||||
# Split large strings containing newlines. null are inserted when a
|
||||
# pattern within the current did not match anything.
|
||||
assert split "[[:space:]]+|([',.!?])" ''
|
||||
Nix Rocks!
|
||||
That's why I use it.
|
||||
'' == [
|
||||
"Nix" [ null ] "Rocks" ["!"] "" [ null ]
|
||||
"That" ["'"] "s" [ null ] "why" [ null ] "I" [ null ] "use" [ null ] "it" ["."] "" [ null ]
|
||||
""
|
||||
];
|
||||
|
||||
# Documentation examples
|
||||
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" ] " " ];
|
||||
|
||||
true
|
||||
|
|
@ -0,0 +1 @@
|
|||
[ "faabar" "fbar" "fubar" "faboor" "fubar" "XaXbXcX" "X" "a_b" ]
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
with builtins;
|
||||
|
||||
[ (replaceStrings ["o"] ["a"] "foobar")
|
||||
(replaceStrings ["o"] [""] "foobar")
|
||||
(replaceStrings ["oo"] ["u"] "foobar")
|
||||
(replaceStrings ["oo" "a"] ["a" "oo"] "foobar")
|
||||
(replaceStrings ["oo" "oo"] ["u" "i"] "foobar")
|
||||
(replaceStrings [""] ["X"] "abc")
|
||||
(replaceStrings [""] ["X"] "")
|
||||
(replaceStrings ["-"] ["_"] "a-b")
|
||||
]
|
||||
|
|
@ -0,0 +1 @@
|
|||
"abccX"
|
||||
|
|
@ -0,0 +1 @@
|
|||
-I lang/dir1 -I lang/dir2 -I dir5=lang/dir3
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
with import ./lib.nix;
|
||||
with builtins;
|
||||
|
||||
assert pathExists <nix/buildenv.nix>;
|
||||
|
||||
assert length __nixPath == 6;
|
||||
assert length (filter (x: x.prefix == "nix") __nixPath) == 1;
|
||||
assert length (filter (x: baseNameOf x.path == "dir4") __nixPath) == 1;
|
||||
|
||||
import <a.nix> + import <b.nix> + import <c.nix> + import <dir5/c.nix>
|
||||
+ (let __nixPath = [ { path = ./dir2; } { path = ./dir1; } ]; in import <a.nix>)
|
||||
|
|
@ -0,0 +1 @@
|
|||
[ [ 42 77 147 249 483 526 ] [ 526 483 249 147 77 42 ] [ "bar" "fnord" "foo" "xyzzy" ] [ { key = 1; value = "foo"; } { key = 1; value = "fnord"; } { key = 2; value = "bar"; } ] ]
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
with builtins;
|
||||
|
||||
[ (sort lessThan [ 483 249 526 147 42 77 ])
|
||||
(sort (x: y: y < x) [ 483 249 526 147 42 77 ])
|
||||
(sort lessThan [ "foo" "bar" "xyzzy" "fnord" ])
|
||||
(sort (x: y: x.key < y.key)
|
||||
[ { key = 1; value = "foo"; } { key = 2; value = "bar"; } { key = 1; value = "fnord"; } ])
|
||||
]
|
||||
|
|
@ -0,0 +1 @@
|
|||
"{\"a\":123,\"b\":-456,\"c\":\"foo\",\"d\":\"foo\\n\\\"bar\\\"\",\"e\":true,\"f\":false,\"g\":[1,2,3],\"h\":[\"a\",[\"b\",{\"foo\\nbar\":{}}]],\"i\":3,\"j\":1.44,\"k\":\"foo\"}"
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
builtins.toJSON
|
||||
{ a = 123;
|
||||
b = -456;
|
||||
c = "foo";
|
||||
d = "foo\n\"bar\"";
|
||||
e = true;
|
||||
f = false;
|
||||
g = [ 1 2 3 ];
|
||||
h = [ "a" [ "b" { "foo\nbar" = {}; } ] ];
|
||||
i = 1 + 2;
|
||||
j = 1.44;
|
||||
k = { __toString = self: self.a; a = "foo"; };
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
"<?xml version='1.0' encoding='utf-8'?>\n<expr>\n <attrs>\n <attr name=\"a\">\n <string value=\"s\" />\n </attr>\n </attrs>\n</expr>\n"
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
# Make sure the expected XML output is produced; in particular, make sure it
|
||||
# doesn't contain source location information.
|
||||
builtins.toXML { a = "s"; }
|
||||
|
|
@ -0,0 +1 @@
|
|||
"<?xml version='1.0' encoding='utf-8'?>\n<expr>\n <list>\n <string value=\"ab\" />\n <int value=\"10\" />\n <attrs>\n <attr name=\"x\">\n <string value=\"x\" />\n </attr>\n <attr name=\"y\">\n <string value=\"x\" />\n </attr>\n </attrs>\n </list>\n</expr>\n"
|
||||
|
|
@ -0,0 +1 @@
|
|||
builtins.toXML [("a" + "b") 10 (rec {x = "x"; y = x;})]
|
||||
|
|
@ -0,0 +1,52 @@
|
|||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<expr>
|
||||
<attrs>
|
||||
<attr name="a">
|
||||
<string value="foo" />
|
||||
</attr>
|
||||
<attr name="at">
|
||||
<function>
|
||||
<attrspat name="args">
|
||||
<attr name="x" />
|
||||
<attr name="y" />
|
||||
<attr name="z" />
|
||||
</attrspat>
|
||||
</function>
|
||||
</attr>
|
||||
<attr name="b">
|
||||
<string value="bar" />
|
||||
</attr>
|
||||
<attr name="c">
|
||||
<string value="foobar" />
|
||||
</attr>
|
||||
<attr name="ellipsis">
|
||||
<function>
|
||||
<attrspat ellipsis="1">
|
||||
<attr name="x" />
|
||||
<attr name="y" />
|
||||
<attr name="z" />
|
||||
</attrspat>
|
||||
</function>
|
||||
</attr>
|
||||
<attr name="f">
|
||||
<function>
|
||||
<attrspat>
|
||||
<attr name="z" />
|
||||
<attr name="x" />
|
||||
<attr name="y" />
|
||||
</attrspat>
|
||||
</function>
|
||||
</attr>
|
||||
<attr name="id">
|
||||
<function>
|
||||
<varpat name="x" />
|
||||
</function>
|
||||
</attr>
|
||||
<attr name="x">
|
||||
<int value="123" />
|
||||
</attr>
|
||||
<attr name="y">
|
||||
<float value="567.89" />
|
||||
</attr>
|
||||
</attrs>
|
||||
</expr>
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
rec {
|
||||
|
||||
x = 123;
|
||||
|
||||
y = 567.890;
|
||||
|
||||
a = "foo";
|
||||
|
||||
b = "bar";
|
||||
|
||||
c = "foo" + "bar";
|
||||
|
||||
f = {z, x, y}: if y then x else z;
|
||||
|
||||
id = x: x;
|
||||
|
||||
at = args@{x, y, z}: x;
|
||||
|
||||
ellipsis = {x, y, z, ...}: x;
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue