brewery
notashelf /
49f64c9c98c1477289fce86b175eb203ab5d3f15

nixir

public

Import-resolving Nix IR plugin

Star0tarball
clone
ssh://git@git.notashelf.dev:33/notashelf/nixir.git

Commit 49f64c9c98c1

tarball

NotAShelf <raf@notashelf.dev> · 2026-02-21 21:07 UTC

unverified28 files changed+151-0
tests: initial test suite for IR compiler

Signed-off-by: NotAShelf <raf@notashelf.dev>
Change-Id: I70cd1dfa45add9df58a44add69fbd30a6a6a6964
diff --git a/tests/attrset.nix b/tests/attrset.nixnew file mode 100644index 0000000..18425c5--- /dev/null+++ b/tests/attrset.nix@@ -0,0 +1,8 @@+# Attrset test+{+  name = "test";+  value = 123;+  nested = {+    inner = true;+  };+}diff --git a/tests/attrset.nixir b/tests/attrset.nixirnew file mode 100644index 0000000..ad8b3e2Binary files /dev/null and b/tests/attrset.nixir differdiff --git a/tests/attrset_var.nix b/tests/attrset_var.nixnew file mode 100644index 0000000..11e1da6--- /dev/null+++ b/tests/attrset_var.nix@@ -0,0 +1,4 @@+let+  x = 10;+in+  { a = x; }diff --git a/tests/comparison.nix b/tests/comparison.nixnew file mode 100644index 0000000..be42016--- /dev/null+++ b/tests/comparison.nix@@ -0,0 +1,6 @@+# Test comparison operators+let+  a = 10;+  b = 20;+in+  if a < b then true else falsediff --git a/tests/comparison.nixir b/tests/comparison.nixirnew file mode 100644index 0000000..3b41e90Binary files /dev/null and b/tests/comparison.nixir differdiff --git a/tests/if.nix b/tests/if.nixnew file mode 100644index 0000000..0ef94a5--- /dev/null+++ b/tests/if.nix@@ -0,0 +1,2 @@+# Conditional test+if true then 1 else 2diff --git a/tests/if.nixir b/tests/if.nixirnew file mode 100644index 0000000..2668f3fBinary files /dev/null and b/tests/if.nixir differdiff --git a/tests/inherit.nix b/tests/inherit.nixnew file mode 100644index 0000000..470cccc--- /dev/null+++ b/tests/inherit.nix@@ -0,0 +1,17 @@+# Test inherit keyword+let+  x = 10;+  y = 20;+  attrs = { a = 1; b = 2; c = 3; };+in+  {+    # Basic inherit from outer scope+    inherit x y;++    # Inherit from expression+    inherit (attrs) a b;++    # Mixed+    z = 30;+    inherit (attrs) c;+  }diff --git a/tests/inherit_from.nix b/tests/inherit_from.nixnew file mode 100644index 0000000..e2d3797--- /dev/null+++ b/tests/inherit_from.nix@@ -0,0 +1,4 @@+let+  attrs = { a = 1; };+in+  { inherit (attrs) a; }diff --git a/tests/inherit_simple.nix b/tests/inherit_simple.nixnew file mode 100644index 0000000..6c004ca--- /dev/null+++ b/tests/inherit_simple.nix@@ -0,0 +1,4 @@+let+  x = 10;+in+  { inherit x; }diff --git a/tests/lambda_pattern.nix b/tests/lambda_pattern.nixnew file mode 100644index 0000000..618558d--- /dev/null+++ b/tests/lambda_pattern.nix@@ -0,0 +1,36 @@+# Test lambda patterns+let+  # Basic destructuring+  f1 = { a, b }: a + b;++  # With default values+  f2 = { a, b ? 10 }: a + b;++  # With ellipsis (extra fields allowed)+  f3 = { a, ... }: a * 2;++  # Named pattern+  f4 = arg@{ a, b }: a + b + arg.c;++  # Simple lambda (not a pattern)+  f5 = x: x + 1;+in+  {+    # Test basic destructuring+    test1 = f1 { a = 3; b = 4; };++    # Test with defaults (provide both)+    test2a = f2 { a = 5; b = 6; };++    # Test with defaults (use default for b)+    test2b = f2 { a = 5; };++    # Test ellipsis (extra field ignored)+    test3 = f3 { a = 7; extra = 999; };++    # Test named pattern+    test4 = f4 { a = 1; b = 2; c = 3; };++    # Test simple lambda+    test5 = f5 10;+  }diff --git a/tests/let.nix b/tests/let.nixnew file mode 100644index 0000000..d9c706b--- /dev/null+++ b/tests/let.nix@@ -0,0 +1,5 @@+# Let binding test+let+  x = 10;+  y = 20;+in xdiff --git a/tests/let.nixir b/tests/let.nixirnew file mode 100644index 0000000..dc6028cBinary files /dev/null and b/tests/let.nixir differdiff --git a/tests/logical.nix b/tests/logical.nixnew file mode 100644index 0000000..e2e2dac--- /dev/null+++ b/tests/logical.nix@@ -0,0 +1,6 @@+# Test logical operators+let+  x = true;+  y = false;+in+  if x && y then 1 else if x || y then 2 else 3diff --git a/tests/logical.nixir b/tests/logical.nixirnew file mode 100644index 0000000..2544d5cBinary files /dev/null and b/tests/logical.nixir differdiff --git a/tests/operators.nix b/tests/operators.nixnew file mode 100644index 0000000..c9e383b--- /dev/null+++ b/tests/operators.nix@@ -0,0 +1,6 @@+# Test arithmetic operators+let+  x = 10;+  y = 5;+in+  (x + y) * 2diff --git a/tests/operators.nixir b/tests/operators.nixirnew file mode 100644index 0000000..031c2e6Binary files /dev/null and b/tests/operators.nixir differdiff --git a/tests/precedence.nix b/tests/precedence.nixnew file mode 100644index 0000000..2949308--- /dev/null+++ b/tests/precedence.nix@@ -0,0 +1,8 @@+# Test operator precedence+let+  a = 1 + 2 * 3;        # Should be 1 + (2 * 3) = 7+  b = 10 - 5 - 2;       # Should be (10 - 5) - 2 = 3+  c = true && false || true;  # Should be (true && false) || true = true+  d = 1 < 2 && 3 > 2;   # Should be (1 < 2) && (3 > 2) = true+in+  { a = a; b = b; c = c; d = d; }diff --git a/tests/precedence.nixir b/tests/precedence.nixirnew file mode 100644index 0000000..3488186Binary files /dev/null and b/tests/precedence.nixir differdiff --git a/tests/shortcircuit.nix b/tests/shortcircuit.nixnew file mode 100644index 0000000..063bf70--- /dev/null+++ b/tests/shortcircuit.nix@@ -0,0 +1,11 @@+# Test short-circuit evaluation+let+  alwaysFalse = false;+  alwaysTrue = true;+  x = 10;+in+  {+    and_false = alwaysFalse && alwaysTrue;+    or_true = alwaysTrue || alwaysFalse;+    impl_false = alwaysFalse -> alwaysFalse;+  }diff --git a/tests/shortcircuit2.nix b/tests/shortcircuit2.nixnew file mode 100644index 0000000..b75cf38--- /dev/null+++ b/tests/shortcircuit2.nix@@ -0,0 +1,6 @@+# Test short-circuit evaluation+{+  and_false = false && true;+  or_true = true || false;+  impl_false = false -> false;+}diff --git a/tests/simple.nix b/tests/simple.nixnew file mode 100644index 0000000..68e636c--- /dev/null+++ b/tests/simple.nix@@ -0,0 +1,2 @@+# Simple constant test+42diff --git a/tests/simple.nixir b/tests/simple.nixirnew file mode 100644index 0000000..ee4989fBinary files /dev/null and b/tests/simple.nixir differdiff --git a/tests/simple_op.nix b/tests/simple_op.nixnew file mode 100644index 0000000..193df0b--- /dev/null+++ b/tests/simple_op.nix@@ -0,0 +1 @@+1 + 2\ No newline at end of filediff --git a/tests/simple_op.nixir b/tests/simple_op.nixirnew file mode 100644index 0000000..fa2a99eBinary files /dev/null and b/tests/simple_op.nixir differdiff --git a/tests/string_interp.nix b/tests/string_interp.nixnew file mode 100644index 0000000..b9ae519--- /dev/null+++ b/tests/string_interp.nix@@ -0,0 +1,19 @@+# Test string interpolation+let+  name = "world";+  x = 42;+  bool_val = true;+in+  {+    # Simple interpolation+    greeting = "Hello ${name}!";++    # Multiple interpolations+    multi = "x is ${x} and name is ${name}";++    # Nested expression+    nested = "Result: ${if bool_val then "yes" else "no"}";++    # Just a string (no interpolation)+    plain = "plain text";+  }diff --git a/tests/unary.nix b/tests/unary.nixnew file mode 100644index 0000000..cc7ddab--- /dev/null+++ b/tests/unary.nix@@ -0,0 +1,6 @@+# Test unary operators+let+  x = 10;+  y = true;+in+  { neg = -x; not = !y; }diff --git a/tests/unary.nixir b/tests/unary.nixirnew file mode 100644index 0000000..00c75c6Binary files /dev/null and b/tests/unary.nixir differ