tests: update test cases for newer syntax items; drop old artifacts

Signed-off-by: NotAShelf <raf@notashelf.dev>
Change-Id: I8640148e8e7597924f9c776750c856266a6a6964
This commit is contained in:
raf 2026-02-22 21:49:12 +03:00
commit 00a3d2e585
Signed by: NotAShelf
GPG key ID: 29D95B64378DB4BF
21 changed files with 144 additions and 0 deletions

8
tests/ancient_let.nix 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;
}

Binary file not shown.

12
tests/block_comments.nix Normal file
View file

@ -0,0 +1,12 @@
# 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 */

Binary file not shown.

15
tests/dynamic_attrs.nix 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";
}

11
tests/home_path.nix 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;
}

Binary file not shown.

31
tests/indented_string.nix 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;
}

Binary file not shown.

15
tests/list_concat.nix 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];
}

Binary file not shown.

13
tests/nested_attrs.nix 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;
}

Binary file not shown.

6
tests/or_in_attrset.nix Normal file
View file

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

4
tests/or_simple.nix Normal file
View file

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

13
tests/path_concat.nix 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;
}

Binary file not shown.

View file

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

Binary file not shown.

Binary file not shown.

Binary file not shown.