Test suite works with new syntax

This commit is contained in:
Robert Bendun 2022-10-25 16:20:24 +02:00
parent 8cda4f4d8e
commit 0529a84fb7
5 changed files with 20 additions and 11 deletions

View File

@ -31,6 +31,7 @@ extern "C" {
namespace fs = std::filesystem; namespace fs = std::filesystem;
static bool quiet_mode = false;
static bool ast_only_mode = false; static bool ast_only_mode = false;
static bool enable_repl = false; static bool enable_repl = false;
static unsigned repl_line_number = 1; static unsigned repl_line_number = 1;
@ -173,10 +174,14 @@ struct Runner
interpreter.midi_connection = &midi; interpreter.midi_connection = &midi;
if (output_port) { if (output_port) {
midi.connect_output(*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 { } else {
midi.connect_output(); 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<Value> args) -> Result<Value> { Env::global->force_define("say", +[](Interpreter &interpreter, std::vector<Value> args) -> Result<Value> {
@ -389,6 +394,10 @@ static std::optional<Error> Main(std::span<char const*> args)
continue; continue;
} }
if (arg == "--quiet" || arg == "-q") {
quiet_mode = true;
continue;
}
if (arg == "--ast") { if (arg == "--ast") {
ast_only_mode = true; ast_only_mode = true;
continue; continue;

View File

@ -10,5 +10,5 @@ say (false and 4);
say (true and 4); say (true and 4);
-- Test lazy evaluation -- Test lazy evaluation
(say 32; false) and (say 42); call (say 32; false) and (say 42);
(say 32; true) and (say 42); call (say 32; true) and (say 42);

View File

@ -9,5 +9,5 @@ say (0 or 0);
say (4 or 3); say (4 or 3);
-- Test lazy evaluation -- Test lazy evaluation
(say 42; false) or say 10; call (say 42; false) or say 10;
(say 42; true) or say 10; call (say 42; true) or say 10;

View File

@ -26,8 +26,8 @@ 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

@ -5,7 +5,7 @@ import os
import subprocess import subprocess
TEST_DB = "test_db.json" TEST_DB = "test_db.json"
INTERPRETER = "bin/debug/musique" INTERPRETER = "bin/linux/debug/musique"
@dataclasses.dataclass @dataclasses.dataclass
class Result: class Result:
@ -24,7 +24,7 @@ class TestCase:
def run(self, interpreter: str, source: str, cwd: str): def run(self, interpreter: str, source: str, cwd: str):
result = subprocess.run( result = subprocess.run(
args=[interpreter, source], args=[interpreter, source, "-q"],
capture_output=True, capture_output=True,
cwd=cwd, cwd=cwd,
text=True text=True