From 0a623a10c7e89a80b6dc74445a0ae6240f65723e Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Wed, 13 Jul 2011 12:19:57 +0000 Subject: * Allow a default value in attribute selection by writing x.y.z or default (as originally proposed in https://mail.cs.uu.nl/pipermail/nix-dev/2009-September/002989.html). For instance, an expression like stdenv.lib.attrByPath ["features" "ckSched"] false args can now be written as args.features.ckSched or false --- tests/lang/eval-okay-attrs5.exp | 1 + tests/lang/eval-okay-attrs5.nix | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 tests/lang/eval-okay-attrs5.exp create mode 100644 tests/lang/eval-okay-attrs5.nix (limited to 'tests') diff --git a/tests/lang/eval-okay-attrs5.exp b/tests/lang/eval-okay-attrs5.exp new file mode 100644 index 000000000..ce0430d78 --- /dev/null +++ b/tests/lang/eval-okay-attrs5.exp @@ -0,0 +1 @@ +[ 123 "foo" 456 456 "foo" "xyzzy" "xyzzy" true ] diff --git a/tests/lang/eval-okay-attrs5.nix b/tests/lang/eval-okay-attrs5.nix new file mode 100644 index 000000000..e77ee7a1c --- /dev/null +++ b/tests/lang/eval-okay-attrs5.nix @@ -0,0 +1,21 @@ +with import ./lib.nix; + +let + + as = { x.y.z = 123; a.b.c = 456; }; + + bs = { foo.bar = "foo"; }; + + or = x: y: x || y; + +in + [ as.x.y.z + as.foo or "foo" + as.x.y.bla or as.a.b.c + as.a.b.c or as.x.y.z + as.x.y.bla or bs.foo.bar or "xyzzy" + as.x.y.bla or bs.bar.foo or "xyzzy" + 123.bla or null.foo or "xyzzy" + # Backwards compatibility test. + (fold or [] [true false false]) + ] -- cgit v1.2.3