Skip to content

Commit

Permalink
add cttest for backwards compat of %parse-param with Copy bounds
Browse files Browse the repository at this point in the history
  • Loading branch information
ratmice committed Oct 8, 2024
1 parent b997cce commit 0ae22f0
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
13 changes: 13 additions & 0 deletions lrpar/cttests/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ lrpar_mod!("multitypes.y");
lrlex_mod!("parseparam.l");
lrpar_mod!("parseparam.y");

lrlex_mod!("parseparam_copy.l");
lrpar_mod!("parseparam_copy.y");

lrlex_mod!("passthrough.l");
lrpar_mod!("passthrough.y");

Expand Down Expand Up @@ -247,6 +250,16 @@ fn test_parseparam() {
}
}

#[test]
fn test_parseparam_copy() {
let lexerdef = parseparam_copy_l::lexerdef();
let lexer = lexerdef.lexer("101");
match parseparam_copy_y::parse(&lexer, 3) {
(Some(104), _) => (),
_ => unreachable!(),
}
}

#[test]
fn test_passthrough() {
let lexerdef = passthrough_l::lexerdef();
Expand Down
18 changes: 18 additions & 0 deletions lrpar/cttests/src/parseparam_copy.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Test %parse-param copy
yacckind: Grmtools
grammar: |
%start S
%parse-param p: u64
%%
S -> u64:
// Previously %parse-param required a `Copy` bounds.
// Since then we relaxed the bounds to require `Clone`.
// This tests backwards compatibility of actions that
// rely on the older copy bounds.
'INT' { (move |_| {})(p); check_copy(p); p + $lexer.span_str($1.unwrap().span()).parse::<u64>().unwrap() }
;
%%
fn check_copy<T: Copy>(_: T){}
lexer: |
%%
[0-9]+ 'INT'

0 comments on commit 0ae22f0

Please sign in to comment.