diff --git a/examples/assigments-state-management.mq b/examples/assigments-state-management.mq index 48d8f0e..0246981 100644 --- a/examples/assigments-state-management.mq +++ b/examples/assigments-state-management.mq @@ -1,27 +1,27 @@ ---------------------------------- Simple variable assigment ---------------------------------- -x := 10; -y := 20; -say x; -say y; +x := 10, +y := 20, +say x, +say y, -x = 30; -say x; -say y; +x = 30, +say x, +say y, -x = y; -say x; -say y; +x = y, +say x, +say y, ---------------------------------- Array updates ---------------------------------- -array := flat 1 2 3; -say array; +array := flat 1 2 3, +say array, -array = update array 1 10; -say array; +array = update array 1 10, +say array, -array = update array 1 (array.2); -say array; +array = update array 1 (array.2), +say array, diff --git a/examples/common-array-operations.mq b/examples/common-array-operations.mq index 1e2ad91..c67cec9 100644 --- a/examples/common-array-operations.mq +++ b/examples/common-array-operations.mq @@ -1,5 +1,5 @@ -map := (fn array | result := (); for array (v | result = result & (| fn v) ); result); -drop := (n arr | arr.(range n (len arr))); -take := (n arr | arr.(up n)); -filter := (predicate arr | arr.(map predicate arr)); +map := (fn array | result := (), for array (v | result = result & (| fn v) ), result), +drop := (n arr | arr.(range n (len arr))), +take := (n arr | arr.(up n)), +filter := (predicate arr | arr.(map predicate arr)), diff --git a/examples/control-flow.mq b/examples/control-flow.mq index 019a633..e20669a 100644 --- a/examples/control-flow.mq +++ b/examples/control-flow.mq @@ -1,13 +1,13 @@ -say (if true 4 2); -say (if false 4 2); +say (if true 4 2), +say (if false 4 2), -if true (say 4) (say 2); -if false (say 4) (say 2); +if true (say 4) (say 2), +if false (say 4) (say 2), -n := 0; +n := 0, while (n < 5) ( - say 'while n; - n = n + 1; -); + say 'while n, + n = n + 1, +), diff --git a/examples/factorial.mq b/examples/factorial.mq index a684b0a..acae81f 100644 --- a/examples/factorial.mq +++ b/examples/factorial.mq @@ -9,22 +9,22 @@ factorial_recursive := (n | if (n <= 1) 1 (n * (factorial_recursive (n-1))) -); +), -- Calculate factorial using iterative approach factorial_iterative := (n | - x := 1; - for (range 1 (n+1)) (i | x *= i); + x := 1, + for (range 1 (n+1)) (i | x *= i), x -); +), -- 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 -- 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 | - say (factorial (n)); + say (factorial (n)), ) -); +), diff --git a/examples/fib.mq b/examples/fib.mq index 7874a17..fc8bca3 100644 --- a/examples/fib.mq +++ b/examples/fib.mq @@ -2,4 +2,4 @@ fib := (n | if (n <= 1) n (fib (n-1) + fib (n-2)) -); +), diff --git a/examples/for-elise.mq b/examples/for-elise.mq index 12dce7d..765c76c 100644 --- a/examples/for-elise.mq +++ b/examples/for-elise.mq @@ -2,79 +2,64 @@ "Für Elise in A Minor" by Ludwig van Beethoven WIP implemntation ---------------------------------------------- -oct 5; bpm 72; len (1/16); +oct 5, bpm 72, len (1/16), subsection1 := ( - sim (a 4 en) (a 2 e 3 a 3); - play (oct 4; c e a); + sim (a4 en) (a2 e3 a3), + play (oct 4, c e a), - sim (b 4 en) (e 2 e 3 g# 3); - play (oct 4; e g# b); + sim (b4 en) (e2 e3 g#3), + play (oct 4, e g# b), - sim (c 5 en) (a 2 e 3 a 3); - play (e 4 e 5 d# 5); + sim (c5 en) (a2 e3 a3), + 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); - play (c 4 e 4 a 4); + sim (a4 en) (a2 e3 a3), + play c4 e4 a4, - sim (b 4 en) (e 2 e 3 g# 3); - play (d 4 c 5 b 4); -); + sim (b4 en) (e2 e3 g#3), + play d4 c5 b4, +), section1 := ( n | - play e d#; - play (e d# e b 4 d c); + play e d#, + play e d# e b4 d c, - call subsection1; + call subsection1, if (n == 1) - ( sim (a 4 qn) (a 2 e 3 a 3) ) - ( sim (a 4 en) (a 2 e 3 a 3) - ; play (b 4 c 5 d 5) + ( sim (a4 qn) (a2 e3 a3) ) + ( sim (a4 en) (a2 e3 a3) + , play b4 c5 d5 ) -); +), section2 := ( n | - sim (e 5 den) (c 3 g 3 c 4); - play (g 4 f e); + sim (e5 den) (c3 g3 c4), + play g4 f e, - sim (d 5 den) (g 2 g 3 b 4); - play (f 4 e d); + sim (d 5 den) (g2 g3 b4), + play f4 e d, - sim (c 5 den) (a 2 e 3 a 3); - play (e 4 d c); + sim (c5 den) (a2 e3 a3), + play e4 d c, - sim (b 4 en) (e 2 e 3 e 4); - play (e 4 e 5 e 4 e 4 e 5 e 6 d# 5 e 5 d# 5 e 5 en); + sim (b4 en) (e2 e3 e4), + play (e4 e5 e4 e4 e5 e6 d#5 e5 d#5 e5 en), - play (d# e d# e d#); - play (e d# e b 4 d c); + play d# e d# e d#, + play e d# e b4 d c, - call subsection1; + call subsection1, if (n == 1) - ( sim (a 4 en) (a 2 e 3 a 3) - ; play (b 4 c 5 d 5) + ( sim (a4 en) (a2 e3 a3) + , play (b4 c5 d5) ) -); +), -section1 1; -section1 2; -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); +section1 1, +section1 2, +section2 1, diff --git a/examples/noises.mq b/examples/noises.mq index d664152..9d21230 100644 --- a/examples/noises.mq +++ b/examples/noises.mq @@ -1,25 +1,25 @@ -- todo: cicho, ostatni parametr midi -- todo: for doesn't forwards implicit play context -pick := (array | (shuffle array).0); +pick := (array | (shuffle array).0), hand1_pool := ( - chord (g# 3) (g 4); - chord (d# 3) (d 4); - chord (g 3) (g# 4); - chord (d 3) (d# 4) -); + chord g#3 g4, + chord d#3 d4, + chord g3 g#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) ( - hand1_length := pick (hn; dhn); - hand1 := (set_len hand1_length (pick hand1_pool)); + hand1_length := pick (hn, dhn), + hand1 := (set_len hand1_length (pick hand1_pool)), - hand2 := (); + hand2 := (), 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, +), diff --git a/examples/ode-to-joy.mq b/examples/ode-to-joy.mq index 7adf97e..2d1073c 100644 --- a/examples/ode-to-joy.mq +++ b/examples/ode-to-joy.mq @@ -1,13 +1,13 @@ -C := chord (c 3 1) (g 3 1) (c 4 1); -G := chord (g 3 1) (d 4 1) (g 4 1); +C := chord c3 g3 c4, +G := chord g3 d4 g4, -oct 5; -par C e e f g; -par G g f e d; -par C c c d e; -par G (e 5 (3/8) d 5 (1/8) d 5 (1/2)); -par C e e f g; -par G g f e d; -par C c c d e; -par G (d 5 (1/2) c 5 (1/8)); -par C (c 5 1); +oct 5, +par C e e f g, +par G g f e d, +par C c c d e, +par G (e5 (3/8) d5 (1/8) d5 (1/2)), +par C e e f g, +par G g f e d, +par C c c d e, +par G (d5 (1/2) c5 (1/8)), +par C (c5 1), diff --git a/examples/permutations.mq b/examples/permutations.mq index 8a6c2c4..b1f90d8 100644 --- a/examples/permutations.mq +++ b/examples/permutations.mq @@ -1,11 +1,11 @@ -factorial := (n | fold '* (1 + up n)); +factorial := (n | fold '* (1 + up n)), list_all_permutations := ( array | for (up (factorial (len array))) (| - say array; - array = permute array; - ); -); + say array, + array = permute array, + ), +), -list_all_permutations (1 + up 5); +list_all_permutations (1 + up 5), diff --git a/examples/play-incoming.mq b/examples/play-incoming.mq deleted file mode 100644 index db22b37..0000000 --- a/examples/play-incoming.mq +++ /dev/null @@ -1,2 +0,0 @@ -incoming 'noteon [channel note velocity | - play (note 4 (1/2)) ]; diff --git a/examples/random-rythm.mq b/examples/random-rythm.mq index db7d9de..ea87e9a 100644 --- a/examples/random-rythm.mq +++ b/examples/random-rythm.mq @@ -1,6 +1,6 @@ -for (up 10) ( n | - snd := c + (shuffle (up 12)).0; - oct := if (n % 2 == 0) 3 4; - say snd oct; - play (snd oct qn); -); +for (up 10) (n | + snd := c + (shuffle (up 12)).0, + o := if (n % 2 == 0) 3 4, + say snd o, + play (oct o, snd qn), +), diff --git a/examples/rhythm-of-primes.mq b/examples/rhythm-of-primes.mq index 7a90dab..5afa97d 100644 --- a/examples/rhythm-of-primes.mq +++ b/examples/rhythm-of-primes.mq @@ -12,7 +12,7 @@ step: 2 3 4 5 6 7 8 9 10 3 3 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 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); -scale := reverse cmajor; -primes := nprimes (len scale); -indicies := up (len scale); +cmajor := (c,d,e,f,g), +scale := reverse cmajor, +primes := nprimes (len scale), +indicies := up (len scale), -oct 3; -len (1/16); +oct 3, +len (1/16), for (2 + up Length) ( i | - play (chord scale.(indicies.(i % primes == 0))); -); + play (chord scale.(indicies.(i % primes == 0))), +), diff --git a/examples/sandattack.mq b/examples/sandattack.mq index 5822446..87ec2ee 100644 --- a/examples/sandattack.mq +++ b/examples/sandattack.mq @@ -1,13 +1,13 @@ -bpm 150; -len sn; +bpm 150, +len sn, play ( - oct 3; 4 * h; h 3 en; - oct 3; 6 * h; h 3 en; - oct 4; 7 * e; - oct 4; 6 * d; - oct 3; a; a; 5 * h; - oct 3; 7 * h; - oct 4; 2 * d; 4 * (h 3); h 3 en -); + oct 3, 4 * h, h3 en, + oct 3, 6 * h, h3 en, + oct 4, 7 * e, + oct 4, 6 * d, + oct 3, a, a, 5 * h, + oct 3, 7 * h, + oct 4, 2 * d, 4 * h3, h3 en +), diff --git a/musique/format.cc b/musique/format.cc index b721106..a2bd943 100644 --- a/musique/format.cc +++ b/musique/format.cc @@ -30,25 +30,25 @@ std::optional Value_Formatter::format(std::ostream& os, Interpreter &inte return {}; }, [&](Array const& array) -> std::optional { - os << '['; + os << '('; for (auto i = 0u; i < array.elements.size(); ++i) { if (i > 0) { - os << "; "; + os << ", "; } Try(nest(Inside_Block).format(os, interpreter, array.elements[i])); } - os << ']'; + os << ')'; return {}; }, [&](Block const& block) -> std::optional { - os << '['; + os << '('; for (auto i = 0u; i < block.size(); ++i) { if (i > 0) { - os << "; "; + os << ", "; } Try(nest(Inside_Block).format(os, interpreter, Try(block.index(interpreter, i)))); } - os << ']'; + os << ')'; return {}; }, [&](auto&&) -> std::optional { diff --git a/musique/lexer/lexer.cc b/musique/lexer/lexer.cc index 442c4f4..ab7da1d 100644 --- a/musique/lexer/lexer.cc +++ b/musique/lexer/lexer.cc @@ -90,7 +90,7 @@ auto Lexer::next_token() -> Result> switch (peek()) { 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::Expression_Separator, finish(), token_location }; + case ',': consume(); return Token { Token::Type::Expression_Separator, finish(), token_location }; case '|': consume(); diff --git a/musique/value/array.cc b/musique/value/array.cc index df8e930..320efda 100644 --- a/musique/value/array.cc +++ b/musique/value/array.cc @@ -29,12 +29,12 @@ usize Array::size() const std::ostream& operator<<(std::ostream& os, Array const& v) { - os << '['; + os << '('; for (auto it = v.elements.begin(); it != v.elements.end(); ++it) { os << *it; if (std::next(it) != v.elements.end()) { - os << "; "; + os << ", "; } } - return os << ']'; + return os << ')'; } diff --git a/musique/value/chord.cc b/musique/value/chord.cc index 113d31d..749d2a0 100644 --- a/musique/value/chord.cc +++ b/musique/value/chord.cc @@ -123,7 +123,7 @@ std::ostream& operator<<(std::ostream& os, Chord const& chord) for (auto it = chord.notes.begin(); it != chord.notes.end(); ++it) { os << *it; if (std::next(it) != chord.notes.end()) - os << "; "; + os << ", "; } return os << ')'; } diff --git a/regression-tests/boolean/logical_and.mq b/regression-tests/boolean/logical_and.mq index 019cf44..4664976 100644 --- a/regression-tests/boolean/logical_and.mq +++ b/regression-tests/boolean/logical_and.mq @@ -1,14 +1,14 @@ -say (false and false); -say (false and true); -say (true and false); -say (true and true); +say (false and false), +say (false and true), +say (true and false), +say (true and true), -- Test value preservation -say (0 and 5); -say (1 and 5); -say (false and 4); -say (true and 4); +say (0 and 5), +say (1 and 5), +say (false and 4), +say (true and 4), -- Test lazy evaluation -call (say 32; false) and (say 42); -call (say 32; true) and (say 42); +call (say 32, false) and (say 42), +call (say 32, true) and (say 42), diff --git a/regression-tests/boolean/logical_or.mq b/regression-tests/boolean/logical_or.mq index 6a7c2b3..7264a64 100644 --- a/regression-tests/boolean/logical_or.mq +++ b/regression-tests/boolean/logical_or.mq @@ -1,13 +1,13 @@ -say (false or false); -say (false or true); -say (true or false); -say (true or true); +say (false or false), +say (false or true), +say (true or false), +say (true or true), -- Test value preservation -say (0 or 1); -say (0 or 0); -say (4 or 3); +say (0 or 1), +say (0 or 0), +say (4 or 3), -- Test lazy evaluation -call (say 42; false) or say 10; -call (say 42; true) or say 10; +call (say 42, false) or say 10, +call (say 42, true) or say 10, diff --git a/regression-tests/builtin/call.mq b/regression-tests/builtin/call.mq index 1774317..30f2e9d 100644 --- a/regression-tests/builtin/call.mq +++ b/regression-tests/builtin/call.mq @@ -1,8 +1,8 @@ -- Call executes blocks without parameters -say (call [42]); +say (call [42]), -- Call executes block passing parameters -say (call [n | n + 1] 10); +say (call [n | n + 1] 10), -- Call executes builtin functions -call say 43; +call say 43, diff --git a/regression-tests/builtin/if.mq b/regression-tests/builtin/if.mq index 5acf312..5262b2c 100644 --- a/regression-tests/builtin/if.mq +++ b/regression-tests/builtin/if.mq @@ -1,13 +1,13 @@ -- If executes then first block when condition is true -if true [say 1]; -if true [say 2] [say 3]; +if true [say 1], +if true [say 2] [say 3], -- 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 -say (if false [say 6]); +say (if false [say 6]), -- If returns block execution value -say (if true [7]); -say (if false [say 100; 8] [say 200; 9]); +say (if true [7]), +say (if false [say 100, 8] [say 200, 9]), diff --git a/regression-tests/builtin/max.mq b/regression-tests/builtin/max.mq index 026854f..c1c8dd9 100644 --- a/regression-tests/builtin/max.mq +++ b/regression-tests/builtin/max.mq @@ -1,6 +1,6 @@ -say (max 1 2 5 4 3); -say (max (200 + up 10)); -say (max (100 + down 10)); +say (max 1 2 5 4 3), +say (max (200 + up 10)), +say (max (100 + down 10)), -- 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), diff --git a/regression-tests/builtin/min.mq b/regression-tests/builtin/min.mq index fe982b8..984b1ec 100644 --- a/regression-tests/builtin/min.mq +++ b/regression-tests/builtin/min.mq @@ -1,6 +1,6 @@ -say (min 1 2 5 4 3); -say (min (200 + up 10)); -say (min (100 + down 10)); +say (min 1 2 5 4 3), +say (min (200 + up 10)), +say (min (100 + down 10)), -- 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), diff --git a/regression-tests/builtin/permute.mq b/regression-tests/builtin/permute.mq index afc4f76..e288220 100644 --- a/regression-tests/builtin/permute.mq +++ b/regression-tests/builtin/permute.mq @@ -1,33 +1,33 @@ -- 4! = 24 permutations -say (permute 0 1 2 3); -say (permute 0 1 3 2); -say (permute 0 2 1 3); -say (permute 0 2 3 1); -say (permute 0 3 1 2); -say (permute 0 3 2 1); -say (permute 1 0 2 3); -say (permute 1 0 3 2); -say (permute 1 2 0 3); -say (permute 1 2 3 0); -say (permute 1 3 0 2); -say (permute 1 3 2 0); -say (permute 2 0 1 3); -say (permute 2 0 3 1); -say (permute 2 1 0 3); -say (permute 2 1 3 0); -say (permute 2 3 0 1); -say (permute 2 3 1 0); -say (permute 3 0 1 2); -say (permute 3 0 2 1); -say (permute 3 1 0 2); -say (permute 3 1 2 0); -say (permute 3 2 0 1); -say (permute 3 2 1 0); +say (permute 0 1 2 3), +say (permute 0 1 3 2), +say (permute 0 2 1 3), +say (permute 0 2 3 1), +say (permute 0 3 1 2), +say (permute 0 3 2 1), +say (permute 1 0 2 3), +say (permute 1 0 3 2), +say (permute 1 2 0 3), +say (permute 1 2 3 0), +say (permute 1 3 0 2), +say (permute 1 3 2 0), +say (permute 2 0 1 3), +say (permute 2 0 3 1), +say (permute 2 1 0 3), +say (permute 2 1 3 0), +say (permute 2 3 0 1), +say (permute 2 3 1 0), +say (permute 3 0 1 2), +say (permute 3 0 2 1), +say (permute 3 1 0 2), +say (permute 3 1 2 0), +say (permute 3 2 0 1), +say (permute 3 2 1 0), -- 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 -say (permute ((3; 2); 4) (1; 0)); -say (permute (0; 1; 4; (3; 2))); +say (permute ((3, 2), 4) (1, 0)), +say (permute (0, 1, 4, (3, 2))), diff --git a/regression-tests/builtin/range.mq b/regression-tests/builtin/range.mq index 959cf2e..61ae424 100644 --- a/regression-tests/builtin/range.mq +++ b/regression-tests/builtin/range.mq @@ -1,17 +1,17 @@ -say (range 0); -say (range (0 - 1)); -say (range 10); -say (range 1 10); -say (range 1 10 2); +say (range 0), +say (range (0 - 1)), +say (range 10), +say (range 1 10), +say (range 1 10 2), -say (up 0); -say (up (0 - 1)); -say (up 10); -say (up 1 10); -say (up 1 10 2); +say (up 0), +say (up (0 - 1)), +say (up 10), +say (up 1 10), +say (up 1 10 2), -say (down 0); -say (down (0 - 1)); -say (down 10); -say (down 1 10); -say (down 1 10 2); +say (down 0), +say (down (0 - 1)), +say (down 10), +say (down 1 10), +say (down 1 10 2), diff --git a/regression-tests/builtin/reverse.mq b/regression-tests/builtin/reverse.mq index ee80fa3..ba7b5f6 100644 --- a/regression-tests/builtin/reverse.mq +++ b/regression-tests/builtin/reverse.mq @@ -1,4 +1,4 @@ -say (reverse []); -say (reverse (up 10)); -say (reverse (reverse (up 10))); -say (reverse [[1; 2; 3]; 4; 5] 6 7 [[8; 9]]); +say (reverse []), +say (reverse (up 10)), +say (reverse (reverse (up 10))), +say (reverse [[1, 2, 3], 4, 5] 6 7 [[8, 9]]), diff --git a/regression-tests/builtin/typeof.mq b/regression-tests/builtin/typeof.mq index 48f0f03..e60aff3 100644 --- a/regression-tests/builtin/typeof.mq +++ b/regression-tests/builtin/typeof.mq @@ -1,7 +1,7 @@ -say (typeof (call flat)); -say (typeof 0); -say (typeof []); -say (typeof c); -say (typeof false); -say (typeof nil); -say (typeof say); +say (typeof (call flat)), +say (typeof 0), +say (typeof []), +say (typeof c), +say (typeof false), +say (typeof nil), +say (typeof say), diff --git a/regression-tests/builtin/uniq.mq b/regression-tests/builtin/uniq.mq index 3d087fc..8b5db01 100644 --- a/regression-tests/builtin/uniq.mq +++ b/regression-tests/builtin/uniq.mq @@ -1,5 +1,5 @@ -say (uniq (up 10 & down 10)); -say (uniq [1;1;1;3;5;3;4;4;1]); +say (uniq (up 10 & down 10)), +say (uniq [1,1,1,3,5,3,4,4,1]), -- 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])), diff --git a/regression-tests/builtin/unique.mq b/regression-tests/builtin/unique.mq index 92a808c..673308b 100644 --- a/regression-tests/builtin/unique.mq +++ b/regression-tests/builtin/unique.mq @@ -1,5 +1,5 @@ -say (unique (up 10 & down 10)); -say (unique [1;1;1;3;5;3;4;4;1]); +say (unique (up 10 & down 10)), +say (unique [1,1,1,3,5,3,4,4,1]), -- 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])), diff --git a/regression-tests/test_db.json b/regression-tests/test_db.json index 43e6bb6..76f188a 100644 --- a/regression-tests/test_db.json +++ b/regression-tests/test_db.json @@ -49,33 +49,33 @@ "exit_code": 0, "stdin_lines": [], "stdout_lines": [ - "[0; 1; 3; 2]", - "[0; 2; 1; 3]", - "[0; 2; 3; 1]", - "[0; 3; 1; 2]", - "[0; 3; 2; 1]", - "[1; 0; 2; 3]", - "[1; 0; 3; 2]", - "[1; 2; 0; 3]", - "[1; 2; 3; 0]", - "[1; 3; 0; 2]", - "[1; 3; 2; 0]", - "[2; 0; 1; 3]", - "[2; 0; 3; 1]", - "[2; 1; 0; 3]", - "[2; 1; 3; 0]", - "[2; 3; 0; 1]", - "[2; 3; 1; 0]", - "[3; 0; 1; 2]", - "[3; 0; 2; 1]", - "[3; 1; 0; 2]", - "[3; 1; 2; 0]", - "[3; 2; 0; 1]", - "[3; 2; 1; 0]", - "[0; 1; 2; 3]", - "[0; 1; 2; 3]", - "[0; 1; 4; [3; 2]]", - "[0; 4; [3; 2]; 1]" + "(0, 1, 3, 2)", + "(0, 2, 1, 3)", + "(0, 2, 3, 1)", + "(0, 3, 1, 2)", + "(0, 3, 2, 1)", + "(1, 0, 2, 3)", + "(1, 0, 3, 2)", + "(1, 2, 0, 3)", + "(1, 2, 3, 0)", + "(1, 3, 0, 2)", + "(1, 3, 2, 0)", + "(2, 0, 1, 3)", + "(2, 0, 3, 1)", + "(2, 1, 0, 3)", + "(2, 1, 3, 0)", + "(2, 3, 0, 1)", + "(2, 3, 1, 0)", + "(3, 0, 1, 2)", + "(3, 0, 2, 1)", + "(3, 1, 0, 2)", + "(3, 1, 2, 0)", + "(3, 2, 0, 1)", + "(3, 2, 1, 0)", + "(0, 1, 2, 3)", + "(0, 1, 2, 3)", + "(0, 1, 4, (3, 2))", + "(0, 4, (3, 2), 1)" ], "stderr_lines": [] }, @@ -84,24 +84,24 @@ "exit_code": 0, "stdin_lines": [], "stdout_lines": [ - "[]", - "[]", - "[0; 1; 2; 3; 4; 5; 6; 7; 8; 9]", - "[1; 2; 3; 4; 5; 6; 7; 8; 9]", - "[1; 3; 5; 7; 9]", - "[]", - "[]", - "[0; 1; 2; 3; 4; 5; 6; 7; 8; 9]", - "[1; 2; 3; 4; 5; 6; 7; 8; 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]", - "[9; 7; 5; 3; 1]" + "()", + "()", + "(0, 1, 2, 3, 4, 5, 6, 7, 8, 9)", + "(1, 2, 3, 4, 5, 6, 7, 8, 9)", + "(1, 3, 5, 7, 9)", + "()", + "()", + "(0, 1, 2, 3, 4, 5, 6, 7, 8, 9)", + "(1, 2, 3, 4, 5, 6, 7, 8, 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)", + "(9, 7, 5, 3, 1)" ], "stderr_lines": [] } ] } -] \ No newline at end of file +] diff --git a/scripts/test.py b/scripts/test.py old mode 100644 new mode 100755 index c0f3123..692e48b --- a/scripts/test.py +++ b/scripts/test.py @@ -1,3 +1,4 @@ +#!/usr/bin/env python3 import argparse import dataclasses import json @@ -139,6 +140,9 @@ def test(): print(f"Passed {successful} out of {total} ({100 * successful // total}%)") 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.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")