From 0529a84fb73098a02d29e9759e8f8da3000e7086 Mon Sep 17 00:00:00 2001 From: Robert Bendun Date: Tue, 25 Oct 2022 16:20:24 +0200 Subject: [PATCH] Test suite works with new syntax --- musique/main.cc | 13 +++++++++++-- regression-tests/boolean/logical_and.mq | 4 ++-- regression-tests/boolean/logical_or.mq | 4 ++-- regression-tests/builtin/permute.mq | 6 +++--- scripts/test.py | 4 ++-- 5 files changed, 20 insertions(+), 11 deletions(-) diff --git a/musique/main.cc b/musique/main.cc index db8fa1d..234b88b 100644 --- a/musique/main.cc +++ b/musique/main.cc @@ -31,6 +31,7 @@ extern "C" { namespace fs = std::filesystem; +static bool quiet_mode = false; static bool ast_only_mode = false; static bool enable_repl = false; static unsigned repl_line_number = 1; @@ -173,10 +174,14 @@ struct Runner interpreter.midi_connection = &midi; if (output_port) { midi.connect_output(*output_port); - std::cout << "Connected MIDI output to port " << *output_port << ". Ready to play!" << std::endl; + if (!quiet_mode) { + std::cout << "Connected MIDI output to port " << *output_port << ". Ready to play!" << std::endl; + } } else { midi.connect_output(); - std::cout << "Created new MIDI output port 'Musique'. Ready to play!" << std::endl; + if (!quiet_mode) { + std::cout << "Created new MIDI output port 'Musique'. Ready to play!" << std::endl; + } } Env::global->force_define("say", +[](Interpreter &interpreter, std::vector args) -> Result { @@ -389,6 +394,10 @@ static std::optional Main(std::span args) continue; } + if (arg == "--quiet" || arg == "-q") { + quiet_mode = true; + continue; + } if (arg == "--ast") { ast_only_mode = true; continue; diff --git a/regression-tests/boolean/logical_and.mq b/regression-tests/boolean/logical_and.mq index 39ae3f7..019cf44 100644 --- a/regression-tests/boolean/logical_and.mq +++ b/regression-tests/boolean/logical_and.mq @@ -10,5 +10,5 @@ say (false and 4); say (true and 4); -- Test lazy evaluation -(say 32; false) and (say 42); -(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 e7a15ba..6a7c2b3 100644 --- a/regression-tests/boolean/logical_or.mq +++ b/regression-tests/boolean/logical_or.mq @@ -9,5 +9,5 @@ say (0 or 0); say (4 or 3); -- Test lazy evaluation -(say 42; false) or say 10; -(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/permute.mq b/regression-tests/builtin/permute.mq index 16ac955..afc4f76 100644 --- a/regression-tests/builtin/permute.mq +++ b/regression-tests/builtin/permute.mq @@ -26,8 +26,8 @@ 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/scripts/test.py b/scripts/test.py index fdd4560..c0f3123 100644 --- a/scripts/test.py +++ b/scripts/test.py @@ -5,7 +5,7 @@ import os import subprocess TEST_DB = "test_db.json" -INTERPRETER = "bin/debug/musique" +INTERPRETER = "bin/linux/debug/musique" @dataclasses.dataclass class Result: @@ -24,7 +24,7 @@ class TestCase: def run(self, interpreter: str, source: str, cwd: str): result = subprocess.run( - args=[interpreter, source], + args=[interpreter, source, "-q"], capture_output=True, cwd=cwd, text=True