Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: port moocode_parsing suite from Stunt #363

Merged
merged 1 commit into from
Aug 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions crates/kernel/testsuite/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ https://github.com/toddsundsted/stunt/tree/master/test
| ✅ | `test_looping.rb` | `looping.moot` | |
| 🚫 | `test_map.rb` | N/A | `moor` doesn't support this Stunt extension. |
| ✅ | `test_math.rb` | `math.moot` | |
| 🔜 | `test_miscellaneous.rb` | N/A | |
| 🔜 | `test_moocode_parsing.rb` | N/A | |
| 🚫 | `test_miscellaneous.rb` | N/A | `moor` doesn't support this Stunt extension (`isa`) |
| 🔜 | `test_moocode_parsing.rb` | N/A | Dropped tests for Stunt extensions (`^` collection, bitwise operators) |
| 🔜 | `test_objects.rb` | N/A | |
| 🔜 | `test_objects_and_properties.rb` | N/A | |
| 🔜 | `test_objects_and_verbs.rb` | N/A | |
Expand Down
48 changes: 48 additions & 0 deletions crates/kernel/testsuite/moot/moocode_parsing.moot
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
// Adapted from https://github.com/toddsundsted/stunt/blob/a4158f5835f1beb9d754c92fd5b3a137e459aabf/test/test_moocode_parsing.rb

@programmer
// test_that_expression_exception_syntax_works
@programmer
; return `args ! ANY => 0';
{}

// test_that_greater_than_syntax_works
@programmer
; return 3 > 2;
1

// test_that_greater_than_or_equal_to_syntax_works
@programmer
; return 3 >= 2;
1

// test_that_less_than_syntax_works
@programmer
; return 2 < 3;
1

// test_that_less_than_or_equal_to_syntax_works
@programmer
; return 2 <= 3;
1

// test_that_and_syntax_works
@programmer
; return 2 && 3;
3

// test_that_or_syntax_works
@programmer
; return 2 || 3;
2

// test_that_dollar_sign_collection_syntax_works
@programmer
; return {1, 2, 3}[$];
3

; return {1, 2, 3}[-1 + $ .. $];
{2, 3}

; return {1, 2, 3}[-1 + $..$];
{2, 3}
2 changes: 1 addition & 1 deletion crates/kernel/testsuite/moot_suite.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,5 +164,5 @@ fn test(db: Box<dyn Database>, path: &Path) {
fn test_single() {
// cargo test -p moor-kernel --test moot-suite test_single -- --ignored
// CARGO_PROFILE_RELEASE_DEBUG=true cargo flamegraph --test moot-suite -- test_single --ignored
test_wiredtiger(&testsuite_dir().join("moot/single.moot"));
test_wiredtiger(&testsuite_dir().join("moot/moocode_parsing.moot"));
}
2 changes: 1 addition & 1 deletion crates/moot/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,7 @@ pub fn execute_moot_test<R: MootRunner, F: Fn() -> eyre::Result<()>>(
let line_no = line_no + 1;
state = state
.process_line(line_no, &line)
.unwrap_or_else(|_| panic!("{}:{line_no}", path.display()))
.unwrap_or_else(|e| panic!("{}:{line_no}: {e:?}", path.display()))
//eprintln!("[{line_no}] {line}");
}
state.finalize().expect("EOF");
Expand Down
2 changes: 1 addition & 1 deletion crates/moot/tests/moot_lmoo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,6 @@ fn test_moo(path: &Path) {
fn test_single() {
test_moo(
&PathBuf::from(env!("CARGO_MANIFEST_DIR"))
.join("../telnet-host/tests/moot/suspend_read_notify.moot"),
.join("../kernel/testsuite/moot/moocode_parsing.moot"),
);
}
Loading