moved from ';' to ',' as expression separator

This commit is contained in:
Robert Bendun 2022-10-27 22:32:20 +02:00
parent e4797d08e1
commit d4c3dbb280
31 changed files with 285 additions and 298 deletions

View File

@ -1,27 +1,27 @@
---------------------------------- ----------------------------------
Simple variable assigment Simple variable assigment
---------------------------------- ----------------------------------
x := 10; x := 10,
y := 20; y := 20,
say x; say x,
say y; say y,
x = 30; x = 30,
say x; say x,
say y; say y,
x = y; x = y,
say x; say x,
say y; say y,
---------------------------------- ----------------------------------
Array updates Array updates
---------------------------------- ----------------------------------
array := flat 1 2 3; array := flat 1 2 3,
say array; say array,
array = update array 1 10; array = update array 1 10,
say array; say array,
array = update array 1 (array.2); array = update array 1 (array.2),
say array; say array,

View File

@ -1,5 +1,5 @@
map := (fn array | result := (); for array (v | result = result & (| fn v) ); result); map := (fn array | result := (), for array (v | result = result & (| fn v) ), result),
drop := (n arr | arr.(range n (len arr))); drop := (n arr | arr.(range n (len arr))),
take := (n arr | arr.(up n)); take := (n arr | arr.(up n)),
filter := (predicate arr | arr.(map predicate arr)); filter := (predicate arr | arr.(map predicate arr)),

View File

@ -1,13 +1,13 @@
say (if true 4 2); say (if true 4 2),
say (if false 4 2); say (if false 4 2),
if true (say 4) (say 2); if true (say 4) (say 2),
if false (say 4) (say 2); if false (say 4) (say 2),
n := 0; n := 0,
while (n < 5) ( while (n < 5) (
say 'while n; say 'while n,
n = n + 1; n = n + 1,
); ),

View File

@ -9,22 +9,22 @@ factorial_recursive := (n |
if (n <= 1) if (n <= 1)
1 1
(n * (factorial_recursive (n-1))) (n * (factorial_recursive (n-1)))
); ),
-- Calculate factorial using iterative approach -- Calculate factorial using iterative approach
factorial_iterative := (n | factorial_iterative := (n |
x := 1; x := 1,
for (range 1 (n+1)) (i | x *= i); for (range 1 (n+1)) (i | x *= i),
x x
); ),
-- Calculate factorial using composition of functions -- Calculate factorial using composition of functions
factorial := (n | fold '* 1 (1 + up n)); factorial := (n | fold '* 1 (1 + up n)),
-- Gather all functions into array, and iterate over it -- Gather all functions into array, and iterate over it
-- This allows to reduce repeatition of this test case -- This allows to reduce repeatition of this test case
for (factorial_recursive; factorial_iterative; factorial) ( factorial | for (factorial_recursive, factorial_iterative, factorial) ( factorial |
for (up 10) ( n | for (up 10) ( n |
say (factorial (n)); say (factorial (n)),
) )
); ),

View File

@ -2,4 +2,4 @@ fib := (n |
if (n <= 1) if (n <= 1)
n n
(fib (n-1) + fib (n-2)) (fib (n-1) + fib (n-2))
); ),

View File

@ -2,79 +2,64 @@
"Für Elise in A Minor" by Ludwig van Beethoven "Für Elise in A Minor" by Ludwig van Beethoven
WIP implemntation WIP implemntation
---------------------------------------------- ----------------------------------------------
oct 5; bpm 72; len (1/16); oct 5, bpm 72, len (1/16),
subsection1 := ( subsection1 := (
sim (a 4 en) (a 2 e 3 a 3); sim (a4 en) (a2 e3 a3),
play (oct 4; c e a); play (oct 4, c e a),
sim (b 4 en) (e 2 e 3 g# 3); sim (b4 en) (e2 e3 g#3),
play (oct 4; e g# b); play (oct 4, e g# b),
sim (c 5 en) (a 2 e 3 a 3); sim (c5 en) (a2 e3 a3),
play (e 4 e 5 d# 5); play (e4 e5 d#5),
play (e d# e b 4 d c); play e d# e b4 d c,
sim (a 4 en) (a 2 e 3 a 3); sim (a4 en) (a2 e3 a3),
play (c 4 e 4 a 4); play c4 e4 a4,
sim (b 4 en) (e 2 e 3 g# 3); sim (b4 en) (e2 e3 g#3),
play (d 4 c 5 b 4); play d4 c5 b4,
); ),
section1 := ( n | section1 := ( n |
play e d#; play e d#,
play (e d# e b 4 d c); play e d# e b4 d c,
call subsection1; call subsection1,
if (n == 1) if (n == 1)
( sim (a 4 qn) (a 2 e 3 a 3) ) ( sim (a4 qn) (a2 e3 a3) )
( sim (a 4 en) (a 2 e 3 a 3) ( sim (a4 en) (a2 e3 a3)
; play (b 4 c 5 d 5) , play b4 c5 d5
) )
); ),
section2 := ( n | section2 := ( n |
sim (e 5 den) (c 3 g 3 c 4); sim (e5 den) (c3 g3 c4),
play (g 4 f e); play g4 f e,
sim (d 5 den) (g 2 g 3 b 4); sim (d 5 den) (g2 g3 b4),
play (f 4 e d); play f4 e d,
sim (c 5 den) (a 2 e 3 a 3); sim (c5 den) (a2 e3 a3),
play (e 4 d c); play e4 d c,
sim (b 4 en) (e 2 e 3 e 4); sim (b4 en) (e2 e3 e4),
play (e 4 e 5 e 4 e 4 e 5 e 6 d# 5 e 5 d# 5 e 5 en); play (e4 e5 e4 e4 e5 e6 d#5 e5 d#5 e5 en),
play (d# e d# e d#); play d# e d# e d#,
play (e d# e b 4 d c); play e d# e b4 d c,
call subsection1; call subsection1,
if (n == 1) if (n == 1)
( sim (a 4 en) (a 2 e 3 a 3) ( sim (a4 en) (a2 e3 a3)
; play (b 4 c 5 d 5) , play (b4 c5 d5)
) )
); ),
section1 1; section1 1,
section1 2; section1 2,
section2 1; section2 1,
sim (a 4 en p e8 4 f7 4 e38 4)
(a 2 e 3 a 3 a#2 3 a3 3 g35 3);
sim (c 5 qn f 5 dsn e 5 tn)
(f 3 a 3 c 4 a 3 c 4 a 3);
sim (e 5 en d 5 en a# 5 dsn a 5 tn)
(f 3 a# 3 d 4 a# 3 d 4 a# 3);
sim (a g f e d c)
(f 3 a# 3 d 4 a# 3 d 4 a# 3);
sim (a# 4 a 4 a 4 tn g 4 tn a 4 tn a# 4 tn)
(f 3 a 3 c 4 a 3 c 4 a 3);

View File

@ -1,25 +1,25 @@
-- todo: cicho, ostatni parametr midi -- todo: cicho, ostatni parametr midi
-- todo: for doesn't forwards implicit play context -- todo: for doesn't forwards implicit play context
pick := (array | (shuffle array).0); pick := (array | (shuffle array).0),
hand1_pool := ( hand1_pool := (
chord (g# 3) (g 4); chord g#3 g4,
chord (d# 3) (d 4); chord d#3 d4,
chord (g 3) (g# 4); chord g3 g#4,
chord (d 3) (d# 4) chord d3 d#4,
); ),
hand2_pool := (d 8; d# 8; g 8; g# 8; d 9; d# 9); hand2_pool := (d8, d#8, g8, g#8, d9, d#9),
for (up 10) ( for (up 10) (
hand1_length := pick (hn; dhn); hand1_length := pick (hn, dhn),
hand1 := (set_len hand1_length (pick hand1_pool)); hand1 := (set_len hand1_length (pick hand1_pool)),
hand2 := (); hand2 := (),
while (fold '+ (map duration hand2) != hand1_length) ( while (fold '+ (map duration hand2) != hand1_length) (
hand2 = flat hand2 (set_len (1/64) (pick hand2_pool)); hand2 = flat hand2 (set_len (1/64) (pick hand2_pool)),
); ),
sim hand1 hand2; sim hand1 hand2,
); ),

View File

@ -1,13 +1,13 @@
C := chord (c 3 1) (g 3 1) (c 4 1); C := chord c3 g3 c4,
G := chord (g 3 1) (d 4 1) (g 4 1); G := chord g3 d4 g4,
oct 5; oct 5,
par C e e f g; par C e e f g,
par G g f e d; par G g f e d,
par C c c d e; par C c c d e,
par G (e 5 (3/8) d 5 (1/8) d 5 (1/2)); par G (e5 (3/8) d5 (1/8) d5 (1/2)),
par C e e f g; par C e e f g,
par G g f e d; par G g f e d,
par C c c d e; par C c c d e,
par G (d 5 (1/2) c 5 (1/8)); par G (d5 (1/2) c5 (1/8)),
par C (c 5 1); par C (c5 1),

View File

@ -1,11 +1,11 @@
factorial := (n | fold '* (1 + up n)); factorial := (n | fold '* (1 + up n)),
list_all_permutations := ( array | list_all_permutations := ( array |
for (up (factorial (len array))) (| for (up (factorial (len array))) (|
say array; say array,
array = permute array; array = permute array,
); ),
); ),
list_all_permutations (1 + up 5); list_all_permutations (1 + up 5),

View File

@ -1,2 +0,0 @@
incoming 'noteon [channel note velocity |
play (note 4 (1/2)) ];

View File

@ -1,6 +1,6 @@
for (up 10) ( n | for (up 10) (n |
snd := c + (shuffle (up 12)).0; snd := c + (shuffle (up 12)).0,
oct := if (n % 2 == 0) 3 4; o := if (n % 2 == 0) 3 4,
say snd oct; say snd o,
play (snd oct qn); play (oct o, snd qn),
); ),

View File

@ -12,7 +12,7 @@ step: 2 3 4 5 6 7 8 9 10
3 3 3 3
where each index corresponds to specific note from scale. where each index corresponds to specific note from scale.
Assuming scale [c;d;e] example above would be Assuming scale [c,d,e] example above would be
step: 2 3 4 5 6 7 8 9 10 step: 2 3 4 5 6 7 8 9 10
c c c c c c c c c c
@ -25,16 +25,16 @@ play c d c e (c & d) c d (c & e)
-------------------------------------------------------------- --------------------------------------------------------------
Length := 40; Length := 40,
cmajor := (c;d;e;f;g); cmajor := (c,d,e,f,g),
scale := reverse cmajor; scale := reverse cmajor,
primes := nprimes (len scale); primes := nprimes (len scale),
indicies := up (len scale); indicies := up (len scale),
oct 3; oct 3,
len (1/16); len (1/16),
for (2 + up Length) ( i | for (2 + up Length) ( i |
play (chord scale.(indicies.(i % primes == 0))); play (chord scale.(indicies.(i % primes == 0))),
); ),

View File

@ -1,13 +1,13 @@
bpm 150; bpm 150,
len sn; len sn,
play ( play (
oct 3; 4 * h; h 3 en; oct 3, 4 * h, h3 en,
oct 3; 6 * h; h 3 en; oct 3, 6 * h, h3 en,
oct 4; 7 * e; oct 4, 7 * e,
oct 4; 6 * d; oct 4, 6 * d,
oct 3; a; a; 5 * h; oct 3, a, a, 5 * h,
oct 3; 7 * h; oct 3, 7 * h,
oct 4; 2 * d; 4 * (h 3); h 3 en oct 4, 2 * d, 4 * h3, h3 en
); ),

View File

@ -30,25 +30,25 @@ std::optional<Error> Value_Formatter::format(std::ostream& os, Interpreter &inte
return {}; return {};
}, },
[&](Array const& array) -> std::optional<Error> { [&](Array const& array) -> std::optional<Error> {
os << '['; os << '(';
for (auto i = 0u; i < array.elements.size(); ++i) { for (auto i = 0u; i < array.elements.size(); ++i) {
if (i > 0) { if (i > 0) {
os << "; "; os << ", ";
} }
Try(nest(Inside_Block).format(os, interpreter, array.elements[i])); Try(nest(Inside_Block).format(os, interpreter, array.elements[i]));
} }
os << ']'; os << ')';
return {}; return {};
}, },
[&](Block const& block) -> std::optional<Error> { [&](Block const& block) -> std::optional<Error> {
os << '['; os << '(';
for (auto i = 0u; i < block.size(); ++i) { for (auto i = 0u; i < block.size(); ++i) {
if (i > 0) { if (i > 0) {
os << "; "; os << ", ";
} }
Try(nest(Inside_Block).format(os, interpreter, Try(block.index(interpreter, i)))); Try(nest(Inside_Block).format(os, interpreter, Try(block.index(interpreter, i))));
} }
os << ']'; os << ')';
return {}; return {};
}, },
[&](auto&&) -> std::optional<Error> { [&](auto&&) -> std::optional<Error> {

View File

@ -90,7 +90,7 @@ auto Lexer::next_token() -> Result<std::variant<Token, End_Of_File>>
switch (peek()) { switch (peek()) {
case '(': consume(); return Token { Token::Type::Open_Block, finish(), token_location }; case '(': consume(); return Token { Token::Type::Open_Block, finish(), token_location };
case ')': consume(); return Token { Token::Type::Close_Block, finish(), token_location }; case ')': consume(); return Token { Token::Type::Close_Block, finish(), token_location };
case ';': consume(); return Token { Token::Type::Expression_Separator, finish(), token_location }; case ',': consume(); return Token { Token::Type::Expression_Separator, finish(), token_location };
case '|': case '|':
consume(); consume();

View File

@ -29,12 +29,12 @@ usize Array::size() const
std::ostream& operator<<(std::ostream& os, Array const& v) std::ostream& operator<<(std::ostream& os, Array const& v)
{ {
os << '['; os << '(';
for (auto it = v.elements.begin(); it != v.elements.end(); ++it) { for (auto it = v.elements.begin(); it != v.elements.end(); ++it) {
os << *it; os << *it;
if (std::next(it) != v.elements.end()) { if (std::next(it) != v.elements.end()) {
os << "; "; os << ", ";
} }
} }
return os << ']'; return os << ')';
} }

View File

@ -123,7 +123,7 @@ std::ostream& operator<<(std::ostream& os, Chord const& chord)
for (auto it = chord.notes.begin(); it != chord.notes.end(); ++it) { for (auto it = chord.notes.begin(); it != chord.notes.end(); ++it) {
os << *it; os << *it;
if (std::next(it) != chord.notes.end()) if (std::next(it) != chord.notes.end())
os << "; "; os << ", ";
} }
return os << ')'; return os << ')';
} }

View File

@ -1,14 +1,14 @@
say (false and false); say (false and false),
say (false and true); say (false and true),
say (true and false); say (true and false),
say (true and true); say (true and true),
-- Test value preservation -- Test value preservation
say (0 and 5); say (0 and 5),
say (1 and 5); say (1 and 5),
say (false and 4); say (false and 4),
say (true and 4); say (true and 4),
-- Test lazy evaluation -- Test lazy evaluation
call (say 32; false) and (say 42); call (say 32, false) and (say 42),
call (say 32; true) and (say 42); call (say 32, true) and (say 42),

View File

@ -1,13 +1,13 @@
say (false or false); say (false or false),
say (false or true); say (false or true),
say (true or false); say (true or false),
say (true or true); say (true or true),
-- Test value preservation -- Test value preservation
say (0 or 1); say (0 or 1),
say (0 or 0); say (0 or 0),
say (4 or 3); say (4 or 3),
-- Test lazy evaluation -- Test lazy evaluation
call (say 42; false) or say 10; call (say 42, false) or say 10,
call (say 42; true) or say 10; call (say 42, true) or say 10,

View File

@ -1,8 +1,8 @@
-- Call executes blocks without parameters -- Call executes blocks without parameters
say (call [42]); say (call [42]),
-- Call executes block passing parameters -- Call executes block passing parameters
say (call [n | n + 1] 10); say (call [n | n + 1] 10),
-- Call executes builtin functions -- Call executes builtin functions
call say 43; call say 43,

View File

@ -1,13 +1,13 @@
-- If executes then first block when condition is true -- If executes then first block when condition is true
if true [say 1]; if true [say 1],
if true [say 2] [say 3]; if true [say 2] [say 3],
-- If executes second block when condition is false -- If executes second block when condition is false
if false [say 4] [say 5]; if false [say 4] [say 5],
-- If returns nil when without else block -- If returns nil when without else block
say (if false [say 6]); say (if false [say 6]),
-- If returns block execution value -- If returns block execution value
say (if true [7]); say (if true [7]),
say (if false [say 100; 8] [say 200; 9]); say (if false [say 100, 8] [say 200, 9]),

View File

@ -1,6 +1,6 @@
say (max 1 2 5 4 3); say (max 1 2 5 4 3),
say (max (200 + up 10)); say (max (200 + up 10)),
say (max (100 + down 10)); say (max (100 + down 10)),
-- Max should do deep search -- Max should do deep search
say (max 1 2 [3; 4; [5; 10; 8]; 1] 2); say (max 1 2 [3, 4, [5, 10, 8], 1] 2),

View File

@ -1,6 +1,6 @@
say (min 1 2 5 4 3); say (min 1 2 5 4 3),
say (min (200 + up 10)); say (min (200 + up 10)),
say (min (100 + down 10)); say (min (100 + down 10)),
-- Min should do deep search -- Min should do deep search
say (min 1 2 [3; 4; [5; 0; 8]; 1] 2); say (min 1 2 [3, 4, [5, 0, 8], 1] 2),

View File

@ -1,33 +1,33 @@
-- 4! = 24 permutations -- 4! = 24 permutations
say (permute 0 1 2 3); say (permute 0 1 2 3),
say (permute 0 1 3 2); say (permute 0 1 3 2),
say (permute 0 2 1 3); say (permute 0 2 1 3),
say (permute 0 2 3 1); say (permute 0 2 3 1),
say (permute 0 3 1 2); say (permute 0 3 1 2),
say (permute 0 3 2 1); say (permute 0 3 2 1),
say (permute 1 0 2 3); say (permute 1 0 2 3),
say (permute 1 0 3 2); say (permute 1 0 3 2),
say (permute 1 2 0 3); say (permute 1 2 0 3),
say (permute 1 2 3 0); say (permute 1 2 3 0),
say (permute 1 3 0 2); say (permute 1 3 0 2),
say (permute 1 3 2 0); say (permute 1 3 2 0),
say (permute 2 0 1 3); say (permute 2 0 1 3),
say (permute 2 0 3 1); say (permute 2 0 3 1),
say (permute 2 1 0 3); say (permute 2 1 0 3),
say (permute 2 1 3 0); say (permute 2 1 3 0),
say (permute 2 3 0 1); say (permute 2 3 0 1),
say (permute 2 3 1 0); say (permute 2 3 1 0),
say (permute 3 0 1 2); say (permute 3 0 1 2),
say (permute 3 0 2 1); say (permute 3 0 2 1),
say (permute 3 1 0 2); say (permute 3 1 0 2),
say (permute 3 1 2 0); say (permute 3 1 2 0),
say (permute 3 2 0 1); say (permute 3 2 0 1),
say (permute 3 2 1 0); say (permute 3 2 1 0),
-- This array should be flattened to support case (permute array) -- This array should be flattened to support case (permute array)
say (permute 3 2 (1; 0)); say (permute 3 2 (1, 0)),
-- Test if nested arrays are preserved -- Test if nested arrays are preserved
say (permute ((3; 2); 4) (1; 0)); say (permute ((3, 2), 4) (1, 0)),
say (permute (0; 1; 4; (3; 2))); say (permute (0, 1, 4, (3, 2))),

View File

@ -1,17 +1,17 @@
say (range 0); say (range 0),
say (range (0 - 1)); say (range (0 - 1)),
say (range 10); say (range 10),
say (range 1 10); say (range 1 10),
say (range 1 10 2); say (range 1 10 2),
say (up 0); say (up 0),
say (up (0 - 1)); say (up (0 - 1)),
say (up 10); say (up 10),
say (up 1 10); say (up 1 10),
say (up 1 10 2); say (up 1 10 2),
say (down 0); say (down 0),
say (down (0 - 1)); say (down (0 - 1)),
say (down 10); say (down 10),
say (down 1 10); say (down 1 10),
say (down 1 10 2); say (down 1 10 2),

View File

@ -1,4 +1,4 @@
say (reverse []); say (reverse []),
say (reverse (up 10)); say (reverse (up 10)),
say (reverse (reverse (up 10))); say (reverse (reverse (up 10))),
say (reverse [[1; 2; 3]; 4; 5] 6 7 [[8; 9]]); say (reverse [[1, 2, 3], 4, 5] 6 7 [[8, 9]]),

View File

@ -1,7 +1,7 @@
say (typeof (call flat)); say (typeof (call flat)),
say (typeof 0); say (typeof 0),
say (typeof []); say (typeof []),
say (typeof c); say (typeof c),
say (typeof false); say (typeof false),
say (typeof nil); say (typeof nil),
say (typeof say); say (typeof say),

View File

@ -1,5 +1,5 @@
say (uniq (up 10 & down 10)); say (uniq (up 10 & down 10)),
say (uniq [1;1;1;3;5;3;4;4;1]); say (uniq [1,1,1,3,5,3,4,4,1]),
-- Multiple uniq applications shouldn't matter -- Multiple uniq applications shouldn't matter
say (uniq (uniq [1;1;1;3;5;3;4;4;1])); say (uniq (uniq [1,1,1,3,5,3,4,4,1])),

View File

@ -1,5 +1,5 @@
say (unique (up 10 & down 10)); say (unique (up 10 & down 10)),
say (unique [1;1;1;3;5;3;4;4;1]); say (unique [1,1,1,3,5,3,4,4,1]),
-- Multiple unique applications shouldn't matter -- Multiple unique applications shouldn't matter
say (unique (unique [1;1;1;3;5;3;4;4;1])); say (unique (unique [1,1,1,3,5,3,4,4,1])),

View File

@ -49,33 +49,33 @@
"exit_code": 0, "exit_code": 0,
"stdin_lines": [], "stdin_lines": [],
"stdout_lines": [ "stdout_lines": [
"[0; 1; 3; 2]", "(0, 1, 3, 2)",
"[0; 2; 1; 3]", "(0, 2, 1, 3)",
"[0; 2; 3; 1]", "(0, 2, 3, 1)",
"[0; 3; 1; 2]", "(0, 3, 1, 2)",
"[0; 3; 2; 1]", "(0, 3, 2, 1)",
"[1; 0; 2; 3]", "(1, 0, 2, 3)",
"[1; 0; 3; 2]", "(1, 0, 3, 2)",
"[1; 2; 0; 3]", "(1, 2, 0, 3)",
"[1; 2; 3; 0]", "(1, 2, 3, 0)",
"[1; 3; 0; 2]", "(1, 3, 0, 2)",
"[1; 3; 2; 0]", "(1, 3, 2, 0)",
"[2; 0; 1; 3]", "(2, 0, 1, 3)",
"[2; 0; 3; 1]", "(2, 0, 3, 1)",
"[2; 1; 0; 3]", "(2, 1, 0, 3)",
"[2; 1; 3; 0]", "(2, 1, 3, 0)",
"[2; 3; 0; 1]", "(2, 3, 0, 1)",
"[2; 3; 1; 0]", "(2, 3, 1, 0)",
"[3; 0; 1; 2]", "(3, 0, 1, 2)",
"[3; 0; 2; 1]", "(3, 0, 2, 1)",
"[3; 1; 0; 2]", "(3, 1, 0, 2)",
"[3; 1; 2; 0]", "(3, 1, 2, 0)",
"[3; 2; 0; 1]", "(3, 2, 0, 1)",
"[3; 2; 1; 0]", "(3, 2, 1, 0)",
"[0; 1; 2; 3]", "(0, 1, 2, 3)",
"[0; 1; 2; 3]", "(0, 1, 2, 3)",
"[0; 1; 4; [3; 2]]", "(0, 1, 4, (3, 2))",
"[0; 4; [3; 2]; 1]" "(0, 4, (3, 2), 1)"
], ],
"stderr_lines": [] "stderr_lines": []
}, },
@ -84,24 +84,24 @@
"exit_code": 0, "exit_code": 0,
"stdin_lines": [], "stdin_lines": [],
"stdout_lines": [ "stdout_lines": [
"[]", "()",
"[]", "()",
"[0; 1; 2; 3; 4; 5; 6; 7; 8; 9]", "(0, 1, 2, 3, 4, 5, 6, 7, 8, 9)",
"[1; 2; 3; 4; 5; 6; 7; 8; 9]", "(1, 2, 3, 4, 5, 6, 7, 8, 9)",
"[1; 3; 5; 7; 9]", "(1, 3, 5, 7, 9)",
"[]", "()",
"[]", "()",
"[0; 1; 2; 3; 4; 5; 6; 7; 8; 9]", "(0, 1, 2, 3, 4, 5, 6, 7, 8, 9)",
"[1; 2; 3; 4; 5; 6; 7; 8; 9]", "(1, 2, 3, 4, 5, 6, 7, 8, 9)",
"[1; 3; 5; 7; 9]", "(1, 3, 5, 7, 9)",
"[]", "()",
"[]", "()",
"[9; 8; 7; 6; 5; 4; 3; 2; 1; 0]", "(9, 8, 7, 6, 5, 4, 3, 2, 1, 0)",
"[9; 8; 7; 6; 5; 4; 3; 2; 1]", "(9, 8, 7, 6, 5, 4, 3, 2, 1)",
"[9; 7; 5; 3; 1]" "(9, 7, 5, 3, 1)"
], ],
"stderr_lines": [] "stderr_lines": []
} }
] ]
} }
] ]

4
scripts/test.py Normal file → Executable file
View File

@ -1,3 +1,4 @@
#!/usr/bin/env python3
import argparse import argparse
import dataclasses import dataclasses
import json import json
@ -139,6 +140,9 @@ def test():
print(f"Passed {successful} out of {total} ({100 * successful // total}%)") print(f"Passed {successful} out of {total} ({100 * successful // total}%)")
if __name__ == "__main__": if __name__ == "__main__":
if not os.path.exists(INTERPRETER):
subprocess.run("make debug", shell=True, check=True)
parser = argparse.ArgumentParser(description="Regression test runner for Musique programming language") parser = argparse.ArgumentParser(description="Regression test runner for Musique programming language")
parser.add_argument("-d", "--discover", action="store_true", help="Discover all tests that are not in testing database") parser.add_argument("-d", "--discover", action="store_true", help="Discover all tests that are not in testing database")
parser.add_argument("-u", "--update", action="store_true", help="Update all tests") parser.add_argument("-u", "--update", action="store_true", help="Update all tests")