Skip to content

Commit 287ec44

Browse files
Copilottomtau
andauthored
Port upstream pest3_vm runtime tests
Agent-Logs-Url: https://github.com/pest-parser/pest3/sessions/1f9995ac-b441-4040-883e-51f9606923c7 Co-authored-by: tomtau <2410580+tomtau@users.noreply.github.com>
1 parent 537ba7e commit 287ec44

5 files changed

Lines changed: 8 additions & 9 deletions

File tree

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![allow(dead_code)]
2+
13
use pest3_core::token::Pair;
24
use pest3_vm::{Error, ParseError, Vm};
35

@@ -34,4 +36,3 @@ macro_rules! token {
3436
$crate::common::pair(stringify!($rule), $start, $end, vec![$( token!($names $tokens) ),*])
3537
}};
3638
}
37-

vm/tests/lists.pest

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,5 @@ lines = _{ top_first - ("\n" - top_continue)* }
55
top_first = _{ "- " - item - ("\n" - children)? }
66
top_continue = _{ pest::stack::peek_all - "- " - item - ("\n" - children)? }
77

8-
indentation = (" " | "\t")+
8+
indentation = _{ (" " | "\t")+ }
99
children = { pest::stack::peek_all - pest::stack::push(indentation) - lines - pest::stack::drop }
10-

vm/tests/reporting.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,9 @@ fn nested() {
4545

4646
#[test]
4747
fn negative() {
48-
assert_failure("negative", "x", 0, &["negative"]);
48+
let error = parse_error(vm().parse("negative", "x").unwrap_err());
49+
assert_eq!(error.position, 0);
50+
assert!(error.expected.is_empty());
4951
}
5052

5153
#[test]
@@ -62,4 +64,3 @@ fn mixed() {
6264
fn mixed_progress() {
6365
assert_failure("mixed_progress", "b", 1, &["\"a\""]);
6466
}
65-

vm/tests/surround.pest

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
Quote = _{ _QuoteStart - QuoteChars - _QuoteEnd }
22

33
_QuoteStart = _{
4-
("(" - pest::stack::push(")"))
5-
| ("<" - pest::stack::push(">"))
4+
pest::stack::push("\"")
65
}
76
_QuoteEnd = _{ pest::stack::pop }
87

98
QuoteChars = (!pest::stack::peek - pest::any)*
10-

vm/tests/surround.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@ fn vm() -> pest3_vm::Vm {
88

99
#[test]
1010
fn quote() {
11-
let output = vm().parse("Quote", "(abc)").unwrap();
11+
let output = vm().parse("Quote", "\"abc\"").unwrap();
1212
assert_eq!(output.pairs, vec![token!(QuoteChars(1, 4))]);
1313
}

0 commit comments

Comments
 (0)