diff --git a/tests/attrset.nix b/tests/attrset.nix new file mode 100644 index 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.nixir new file mode 100644 index 0000000..ad8b3e2 Binary files /dev/null and b/tests/attrset.nixir differ diff --git a/tests/attrset_var.nix b/tests/attrset_var.nix new file mode 100644 index 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.nix new file mode 100644 index 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 false diff --git a/tests/comparison.nixir b/tests/comparison.nixir new file mode 100644 index 0000000..3b41e90 Binary files /dev/null and b/tests/comparison.nixir differ diff --git a/tests/if.nix b/tests/if.nix new file mode 100644 index 0000000..0ef94a5 --- /dev/null +++ b/tests/if.nix @@ -0,0 +1,2 @@ +# Conditional test +if true then 1 else 2 diff --git a/tests/if.nixir b/tests/if.nixir new file mode 100644 index 0000000..2668f3f Binary files /dev/null and b/tests/if.nixir differ diff --git a/tests/inherit.nix b/tests/inherit.nix new file mode 100644 index 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.nix new file mode 100644 index 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.nix new file mode 100644 index 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.nix new file mode 100644 index 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.nix new file mode 100644 index 0000000..d9c706b --- /dev/null +++ b/tests/let.nix @@ -0,0 +1,5 @@ +# Let binding test +let + x = 10; + y = 20; +in x diff --git a/tests/let.nixir b/tests/let.nixir new file mode 100644 index 0000000..dc6028c Binary files /dev/null and b/tests/let.nixir differ diff --git a/tests/logical.nix b/tests/logical.nix new file mode 100644 index 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 3 diff --git a/tests/logical.nixir b/tests/logical.nixir new file mode 100644 index 0000000..2544d5c Binary files /dev/null and b/tests/logical.nixir differ diff --git a/tests/operators.nix b/tests/operators.nix new file mode 100644 index 0000000..c9e383b --- /dev/null +++ b/tests/operators.nix @@ -0,0 +1,6 @@ +# Test arithmetic operators +let + x = 10; + y = 5; +in + (x + y) * 2 diff --git a/tests/operators.nixir b/tests/operators.nixir new file mode 100644 index 0000000..031c2e6 Binary files /dev/null and b/tests/operators.nixir differ diff --git a/tests/precedence.nix b/tests/precedence.nix new file mode 100644 index 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.nixir new file mode 100644 index 0000000..3488186 Binary files /dev/null and b/tests/precedence.nixir differ diff --git a/tests/shortcircuit.nix b/tests/shortcircuit.nix new file mode 100644 index 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.nix new file mode 100644 index 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.nix new file mode 100644 index 0000000..68e636c --- /dev/null +++ b/tests/simple.nix @@ -0,0 +1,2 @@ +# Simple constant test +42 diff --git a/tests/simple.nixir b/tests/simple.nixir new file mode 100644 index 0000000..ee4989f Binary files /dev/null and b/tests/simple.nixir differ diff --git a/tests/simple_op.nix b/tests/simple_op.nix new file mode 100644 index 0000000..193df0b --- /dev/null +++ b/tests/simple_op.nix @@ -0,0 +1 @@ +1 + 2 \ No newline at end of file diff --git a/tests/simple_op.nixir b/tests/simple_op.nixir new file mode 100644 index 0000000..fa2a99e Binary files /dev/null and b/tests/simple_op.nixir differ diff --git a/tests/string_interp.nix b/tests/string_interp.nix new file mode 100644 index 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.nix new file mode 100644 index 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.nixir new file mode 100644 index 0000000..00c75c6 Binary files /dev/null and b/tests/unary.nixir differ