nix: format test fixtures via nix fmt
Signed-off-by: NotAShelf <raf@notashelf.dev> Change-Id: Ia9c1e9b0a8cd9c6d834f153609baa5426a6a6964
This commit is contained in:
parent
e8dd09c5b4
commit
b49044c9a5
15 changed files with 132 additions and 73 deletions
|
|
@ -1,36 +1,61 @@
|
|||
# Test lambda patterns
|
||||
let
|
||||
# Basic destructuring
|
||||
f1 = { a, b }: a + b;
|
||||
f1 = {
|
||||
a,
|
||||
b,
|
||||
}:
|
||||
a + b;
|
||||
|
||||
# With default values
|
||||
f2 = { a, b ? 10 }: a + b;
|
||||
f2 = {
|
||||
a,
|
||||
b ? 10,
|
||||
}:
|
||||
a + b;
|
||||
|
||||
# With ellipsis (extra fields allowed)
|
||||
f3 = { a, ... }: a * 2;
|
||||
f3 = {a, ...}: a * 2;
|
||||
|
||||
# Named pattern with ellipsis to allow extra fields
|
||||
f4 = arg@{ a, b, ... }: a + b + arg.c;
|
||||
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; };
|
||||
in {
|
||||
# Test basic destructuring
|
||||
test1 = f1 {
|
||||
a = 3;
|
||||
b = 4;
|
||||
};
|
||||
|
||||
# Test with defaults (provide both)
|
||||
test2a = f2 { a = 5; b = 6; };
|
||||
# Test with defaults (provide both)
|
||||
test2a = f2 {
|
||||
a = 5;
|
||||
b = 6;
|
||||
};
|
||||
|
||||
# Test with defaults (use default for b)
|
||||
test2b = f2 { a = 5; };
|
||||
# Test with defaults (use default for b)
|
||||
test2b = f2 {a = 5;};
|
||||
|
||||
# Test ellipsis (extra field ignored)
|
||||
test3 = f3 { a = 7; extra = 999; };
|
||||
# Test ellipsis (extra field ignored)
|
||||
test3 = f3 {
|
||||
a = 7;
|
||||
extra = 999;
|
||||
};
|
||||
|
||||
# Test named pattern
|
||||
test4 = f4 { a = 1; b = 2; c = 3; };
|
||||
# Test named pattern
|
||||
test4 = f4 {
|
||||
a = 1;
|
||||
b = 2;
|
||||
c = 3;
|
||||
};
|
||||
|
||||
# Test simple lambda
|
||||
test5 = f5 10;
|
||||
}
|
||||
# Test simple lambda
|
||||
test5 = f5 10;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue