tests: move fixtures to dedicated dir

Signed-off-by: NotAShelf <raf@notashelf.dev>
Change-Id: I9d6ce6a264780f215b1b57d947b5264c6a6a6964
This commit is contained in:
raf 2026-02-23 02:24:48 +03:00
commit ae505188fc
Signed by: NotAShelf
GPG key ID: 29D95B64378DB4BF
75 changed files with 478 additions and 438 deletions

8
tests/fixtures/ancient_let.nix vendored Normal file
View file

@ -0,0 +1,8 @@
# Test ancient let syntax: let { bindings; body = expr; }
# This is equivalent to: let bindings in expr, but has been deprecated
# in newer Nix versions.
let {
x = 10;
y = 20;
body = x + y;
}

8
tests/fixtures/attrset.nix vendored Normal file
View file

@ -0,0 +1,8 @@
# Attrset test
{
name = "test";
value = 123;
nested = {
inner = true;
};
}

3
tests/fixtures/attrset_var.nix vendored Normal file
View file

@ -0,0 +1,3 @@
let
x = 10;
in {a = x;}

24
tests/fixtures/block_comments.nix vendored Normal file
View file

@ -0,0 +1,24 @@
# Test block comments /* */
/*
This is a block comment
*/
let
x = 42;
/*
inline block comment
*/
/*
Multi-line
block
comment
*/
y = 100;
in
/*
Comment before expression
*/
x + y
/*
Trailing comment
*/

8
tests/fixtures/comparison.nix vendored Normal file
View file

@ -0,0 +1,8 @@
# Test comparison operators
let
a = 10;
b = 20;
in
if a < b
then true
else false

14
tests/fixtures/dynamic_attr_full.nix vendored Normal file
View file

@ -0,0 +1,14 @@
# Test dynamic attribute names
let
key = "mykey";
value = 42;
in {
# Dynamic attribute with string interpolation
"${key}" = value;
# Another dynamic attribute
"${key}_suffix" = value + 1;
# Static attribute for comparison
static = 100;
}

15
tests/fixtures/dynamic_attrs.nix vendored Normal file
View file

@ -0,0 +1,15 @@
# Test dynamic attribute names
# Note: Full dynamic attrs require runtime evaluation
# For now, testing that syntax is recognized
let
key = "mykey";
in {
# Static attribute for comparison
static = "value";
# Dynamic attribute name (basic string interpolation)
# "${key}" = "dynamic_value";
# For now, use workaround with static names
mykey = "works";
}

1
tests/fixtures/float_test.nix vendored Normal file
View file

@ -0,0 +1 @@
1.5

11
tests/fixtures/home_path.nix vendored Normal file
View file

@ -0,0 +1,11 @@
# Test home-relative paths
# Note: This will resolve to the actual home directory at evaluation time
let
# Example home path (will be expanded by evaluator)
config = ~/..config;
file = ~/.bashrc;
in {
# These are just path values that will be expanded
configPath = config;
filePath = file;
}

4
tests/fixtures/if.nix vendored Normal file
View file

@ -0,0 +1,4 @@
# Conditional test
if true
then 1
else 2

3
tests/fixtures/import_lookup.nix vendored Normal file
View file

@ -0,0 +1,3 @@
# Test import with lookup path
# Common pattern: import <nixpkgs> { }
import <nixpkgs>

9
tests/fixtures/import_simple.nix vendored Normal file
View file

@ -0,0 +1,9 @@
# Test import expression
# Import evaluates the file and returns its value
# Import a file that returns a simple value (42)
import ./simple.nix
# Can also import lookup paths:
# import <nixpkgs> { }
# Import with path expressions:
# import (./dir + "/file.nix")

31
tests/fixtures/indented_string.nix vendored Normal file
View file

@ -0,0 +1,31 @@
# Test indented strings (multi-line strings with '' delimiters)
let
# Simple indented string
simple = ''
Hello
World
'';
# Indented string with interpolation
name = "Nix";
greeting = ''
Welcome to ${name}!
This is indented.
'';
# Escape sequences
escapes = ''
Literal dollar: ''$
Literal quotes: '''
Regular text
'';
# Shell script example (common use case)
script = ''
#!/bin/bash
echo "Running script"
ls -la
'';
in {
inherit simple greeting escapes script;
}

20
tests/fixtures/inherit.nix vendored Normal file
View file

@ -0,0 +1,20 @@
# 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;
}

3
tests/fixtures/inherit_from.nix vendored Normal file
View file

@ -0,0 +1,3 @@
let
attrs = {a = 1;};
in {inherit (attrs) a;}

3
tests/fixtures/inherit_simple.nix vendored Normal file
View file

@ -0,0 +1,3 @@
let
x = 10;
in {inherit x;}

61
tests/fixtures/lambda_pattern.nix vendored Normal file
View file

@ -0,0 +1,61 @@
# 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 with ellipsis to allow extra fields
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;
}

6
tests/fixtures/let.nix vendored Normal file
View file

@ -0,0 +1,6 @@
# Let binding test
let
x = 10;
y = 20;
in
x

15
tests/fixtures/list_concat.nix vendored Normal file
View file

@ -0,0 +1,15 @@
# Test list concatenation operator ++
let
list1 = [1 2 3];
list2 = [4 5 6];
empty = [];
in {
# Basic concatenation
combined = list1 ++ list2;
# Concatenate with empty list
with_empty = list1 ++ empty;
# Nested concatenation
triple = [1] ++ [2] ++ [3];
}

8
tests/fixtures/list_simple.nix vendored Normal file
View file

@ -0,0 +1,8 @@
# Test basic list support
let
x = [1 2 3];
y = [4 5 6];
z = x ++ y; # List concatenation
in {
inherit x y z;
}

10
tests/fixtures/logical.nix vendored Normal file
View file

@ -0,0 +1,10 @@
# Test logical operators
let
x = true;
y = false;
in
if x && y
then 1
else if x || y
then 2
else 3

8
tests/fixtures/lookup_path.nix vendored Normal file
View file

@ -0,0 +1,8 @@
# Test lookup path syntax
# Lookup paths resolve via NIX_PATH environment variable
# Example: <nixpkgs> -> /nix/var/nix/profiles/per-user/root/channels/nixpkgs
# Simple lookup path
<nixpkgs>
# Nested lookup path (common pattern)
# <nixpkgs/lib>

3
tests/fixtures/lookup_path_nested.nix vendored Normal file
View file

@ -0,0 +1,3 @@
# Test nested lookup path
# Common pattern in Nix: <nixpkgs/lib> or <nixpkgs/pkgs/stdenv>
<nixpkgs/lib>

2
tests/fixtures/merge.nix vendored Normal file
View file

@ -0,0 +1,2 @@
# Test attrset merge operator (//)
{a = {x = 1;} // {y = 2;};}

13
tests/fixtures/nested_attrs.nix vendored Normal file
View file

@ -0,0 +1,13 @@
# Test nested attribute paths
{
# Simple nested path
a.b.c = 42;
# Multiple nested paths
x.y = 1;
x.z = 2;
# Mix of nested and non-nested
foo = "bar";
nested.deep.value = 100;
}

6
tests/fixtures/operators.nix vendored Normal file
View file

@ -0,0 +1,6 @@
# Test arithmetic operators
let
x = 10;
y = 5;
in
(x + y) * 2

6
tests/fixtures/or_in_attrset.nix vendored Normal file
View file

@ -0,0 +1,6 @@
# Test 'or' in attrset context
let
attrs = {a = 1;};
in {
test = attrs.a or 999;
}

5
tests/fixtures/or_simple.nix vendored Normal file
View file

@ -0,0 +1,5 @@
# Simplest 'or' test
let
x = {a = 1;};
in
x.a or 2

13
tests/fixtures/path_concat.nix vendored Normal file
View file

@ -0,0 +1,13 @@
# Test path concatenation
let
# Path + string = path
p1 = ./foo + "/bar";
# String + path = path
p2 = "/prefix" + ./suffix;
# Path + path = path
p3 = ./dir + ./file;
in {
inherit p1 p2 p3;
}

12
tests/fixtures/precedence.nix vendored Normal file
View file

@ -0,0 +1,12 @@
# 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;
}

19
tests/fixtures/select_or_default.nix vendored Normal file
View file

@ -0,0 +1,19 @@
# Test selection with 'or' default
let
attrs = {
a = 1;
b = 2;
};
in {
# Attribute exists - should use value from attrs
has_attr = attrs.a or 999;
# Attribute doesn't exist - should use default
missing_attr = attrs.c or 100;
# Nested default expression
nested = attrs.d or (attrs.a + attrs.b);
# Default with literal
with_string = attrs.name or "default_name";
}

10
tests/fixtures/shortcircuit.nix vendored Normal file
View file

@ -0,0 +1,10 @@
# Test short-circuit evaluation
let
alwaysFalse = false;
alwaysTrue = true;
x = 10;
in {
and_false = alwaysFalse && alwaysTrue;
or_true = alwaysTrue || alwaysFalse;
impl_false = alwaysFalse -> alwaysFalse;
}

6
tests/fixtures/shortcircuit2.nix vendored Normal file
View file

@ -0,0 +1,6 @@
# Test short-circuit evaluation
{
and_false = false && true;
or_true = true || false;
impl_false = false -> false;
}

2
tests/fixtures/simple.nix vendored Normal file
View file

@ -0,0 +1,2 @@
# Simple constant test
42

1
tests/fixtures/simple_op.nix vendored Normal file
View file

@ -0,0 +1 @@
1 + 2

20
tests/fixtures/string_interp.nix vendored Normal file
View file

@ -0,0 +1,20 @@
# 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}";
# Expression evaluation in interpolation
computed = "x + 10 = ${x + 10}";
bool_check = "${bool_val} is true!";
# Just a string, no interpolation
plain = "plain text";
}

8
tests/fixtures/unary.nix vendored Normal file
View file

@ -0,0 +1,8 @@
# Test unary operators
let
x = 10;
y = true;
in {
neg = -x;
not = !y;
}

3
tests/fixtures/uri_test.nix vendored Normal file
View file

@ -0,0 +1,3 @@
https://example.com/path?query=1
#frag