From 49f64c9c98c1477289fce86b175eb203ab5d3f15 Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Sat, 21 Feb 2026 20:48:08 +0300 Subject: [PATCH] tests: initial test suite for IR compiler Signed-off-by: NotAShelf Change-Id: I70cd1dfa45add9df58a44add69fbd30a6a6a6964 --- tests/attrset.nix | 8 ++++++++ tests/attrset.nixir | Bin 0 -> 109 bytes tests/attrset_var.nix | 4 ++++ tests/comparison.nix | 6 ++++++ tests/comparison.nixir | Bin 0 -> 107 bytes tests/if.nix | 2 ++ tests/if.nixir | Bin 0 -> 58 bytes tests/inherit.nix | 17 +++++++++++++++++ tests/inherit_from.nix | 4 ++++ tests/inherit_simple.nix | 4 ++++ tests/lambda_pattern.nix | 36 ++++++++++++++++++++++++++++++++++++ tests/let.nix | 5 +++++ tests/let.nixir | Bin 0 -> 75 bytes tests/logical.nix | 6 ++++++ tests/logical.nixir | Bin 0 -> 149 bytes tests/operators.nix | 6 ++++++ tests/operators.nixir | Bin 0 -> 109 bytes tests/precedence.nix | 8 ++++++++ tests/precedence.nixir | Bin 0 -> 318 bytes tests/shortcircuit.nix | 11 +++++++++++ tests/shortcircuit2.nix | 6 ++++++ tests/simple.nix | 2 ++ tests/simple.nixir | Bin 0 -> 34 bytes tests/simple_op.nix | 1 + tests/simple_op.nixir | Bin 0 -> 53 bytes tests/string_interp.nix | 19 +++++++++++++++++++ tests/unary.nix | 6 ++++++ tests/unary.nixir | Bin 0 -> 113 bytes 28 files changed, 151 insertions(+) create mode 100644 tests/attrset.nix create mode 100644 tests/attrset.nixir create mode 100644 tests/attrset_var.nix create mode 100644 tests/comparison.nix create mode 100644 tests/comparison.nixir create mode 100644 tests/if.nix create mode 100644 tests/if.nixir create mode 100644 tests/inherit.nix create mode 100644 tests/inherit_from.nix create mode 100644 tests/inherit_simple.nix create mode 100644 tests/lambda_pattern.nix create mode 100644 tests/let.nix create mode 100644 tests/let.nixir create mode 100644 tests/logical.nix create mode 100644 tests/logical.nixir create mode 100644 tests/operators.nix create mode 100644 tests/operators.nixir create mode 100644 tests/precedence.nix create mode 100644 tests/precedence.nixir create mode 100644 tests/shortcircuit.nix create mode 100644 tests/shortcircuit2.nix create mode 100644 tests/simple.nix create mode 100644 tests/simple.nixir create mode 100644 tests/simple_op.nix create mode 100644 tests/simple_op.nixir create mode 100644 tests/string_interp.nix create mode 100644 tests/unary.nix create mode 100644 tests/unary.nixir 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 0000000000000000000000000000000000000000..ad8b3e2d6836c80f26d9b6382c7b2980e8bd9f90 GIT binary patch literal 109 zcmazD^7Lb5Kn08jU_LXDWC7y5#N1RSkO+uVl3HBC3Z%;tb4pXe8mmE4K)?pXc|h6J U6o__^BuHguUS4VuNGk&)09^;fPX1i%cCDi#or I5lk`w0PLp&4gdfE literal 0 HcmV?d00001 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 0000000000000000000000000000000000000000..2668f3f78628ac947d2722bc160cffd2ebed17b7 GIT binary patch literal 58 gcmazD^7Lb5Kn08rAU+F-U 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 0000000000000000000000000000000000000000..34881861c5e1f9cbf9ccd9061e0b663f1639ead0 GIT binary patch literal 318 zcmY+9OA3H63`Co%DC)v9cml8CM#Pm{KleX_omY`q=#bZ$gmmBL#lrvCDlXHNbBrR& zED3mu^hMm)FC3hNEGyC0xuNplhg@{@Xs0EDp)3?klkRMyHKP$lm5-8i@Ee}|VxK>e V`u;h9Nz`#ds&p?%b453#kq?@H2Fw5e literal 0 HcmV?d00001 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 0000000000000000000000000000000000000000..ee4989f321a6af3fbb555b83bf86fb1f8eac086d GIT binary patch literal 34 UcmazD^7Lb5Kn09o0WGK?04je0ZvX%Q literal 0 HcmV?d00001 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 0000000000000000000000000000000000000000..fa2a99e7ff07eb831392b19d0ce5ea126620cd74 GIT binary patch literal 53 acmazD^7Lb5Kn09SU_MwFCI_aOpy~icx&dnd literal 0 HcmV?d00001 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 0000000000000000000000000000000000000000..00c75c62a194b746260cf64638ba4c4429a1ec94 GIT binary patch literal 113 zcmazD^7Lb5Kn08eAU+cigJdee(p(@RAOLYHS->m<5D8Ys45af?)0M#j0$>uT5G