Skip to content
Open
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
27 changes: 13 additions & 14 deletions e2e/e2e_test.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,21 @@ async test "valid toml-test suite" {
continue
}
}
let parsed = try? @toml.parse(toml_content)
match parsed {
Err(e) => {
failures.push("[PARSE-ERROR] \{toml_path}: \{e}")
try
let value = @toml.parse(toml_content)
let actual = to_test_json(value)
if !json_equal(actual, expected) {
failures.push(
"[MISMATCH] \{toml_path}\n expected: \{expected.stringify()}\n actual: \{actual.stringify()}",
)
failed += 1
} else {
passed += 1
}
Ok(value) => {
let actual = to_test_json(value)
if !json_equal(actual, expected) {
failures.push(
"[MISMATCH] \{toml_path}\n expected: \{expected.stringify()}\n actual: \{actual.stringify()}",
)
failed += 1
} else {
passed += 1
}
catch {
e => {
failures.push("[PARSE-ERROR] \{toml_path}: \{e}")
failed += 1
}
}
}
Expand Down
32 changes: 16 additions & 16 deletions e2e/runner.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -40,19 +40,18 @@ pub fn run_single_valid_test(toml_path : String) -> String? raise @fs.IOError {
let expected : Json = @json.parse(expected_json_str) catch {
e => return Some("\{toml_path}: failed to parse expected JSON: \{e}")
}
let parsed = try? @toml.parse(toml_content)
match parsed {
Err(e) => Some("[PARSE-ERROR] \{toml_path}: \{e}")
Ok(value) => {
let actual = to_test_json(value)
if !json_equal(actual, expected) {
Some(
"[MISMATCH] \{toml_path}\n expected: \{expected.stringify()}\n actual: \{actual.stringify()}",
)
} else {
None
}
try
let value = @toml.parse(toml_content)
let actual = to_test_json(value)
if !json_equal(actual, expected) {
Some(
"[MISMATCH] \{toml_path}\n expected: \{expected.stringify()}\n actual: \{actual.stringify()}",
)
} else {
None
}
catch {
e => Some("[PARSE-ERROR] \{toml_path}: \{e}")
}
}

Expand All @@ -66,10 +65,11 @@ pub fn run_single_invalid_test(toml_path : String) -> String? raise @fs.IOError
// Non-UTF-8 file: parser would reject this, count as pass
_ => return None
}
let parsed = try? @toml.parse(toml_content)
match parsed {
Ok(_) => Some("[PASS-BUT-SHOULD-FAIL] \{toml_path}")
Err(_) => None
try
let _ = @toml.parse(toml_content)
Some("[PASS-BUT-SHOULD-FAIL] \{toml_path}")
catch {
_ => None
}
}

Expand Down
Loading