Consider
#[rstest]
fn integer_multipleof(#[values(0, 3, 12, 1818)] test_value: i64) {
const MULTIPLE_OF: i64 = 3;
let schema = &json!({"type":"integer", "multipleOf": MULTIPLE_OF});
json_schema_check(schema, &json!(test_value), test_value % MULTIPLE_OF == 0);
}
which passes.
Start changing the test_value to negative numbers, and get:
LexerSpec { lexemes: [
[0] SKIP0 (Or)
[1] SKIP1 (Regex /[\x20\x0A\x0D\x09]+/)
[2] [2] (ExprRef ((('-')? ((['1'-'9'] (['0'-'9'])*) | '0')) & ( % 3 == 3 )))
[3] $extra_0 (Regex /[\x20\x0A\x0D\x09]+/) extra
[4] $extra_1 (Regex /[^"\\\x00-\x1F\x7F]{1,10}/) extra
[5] $extra_2 (Regex /[^"\\\x00-\x1F\x7F]{1,30}/) extra
[6] $extra_3 (Regex /[^"\\\x00-\x1F\x7F]+/) extra
] }
Grammar:
start#2 ==> Name("%nested---1")
start ⇦ start#2
start#2 ⇦ start#3
empty ⇦ ϵ
start#3 ⇦ [2]
stats: 1 terminals; 4 non-terminals with 4 rules with 12 symbols
== Optimize ==>
Grammar:
start#2 ==> Name("%nested---1")
start ⇦ start#2
start#2 ⇦ start#3
start#3 ⇦ [2]
empty ⇦ ϵ
stats: 1 terminals; 4 non-terminals with 4 rules with 12 symbols
build grammar: 16.0421ms; optimize: 151.5µs
initial lexer cost: regexps: 7 with 57 nodes (+ 44 derived via 832 derivatives with total fuel 2819), states: 18; transitions: 26; bytes: 61299; alphabet size: 26 (no prompt)
compute_mask
step-stats: 220us; 16 lex fuel; 3 items; regexps: 7 with 57 nodes (+ 44 derived via 841 derivatives with total fuel 2835), states: 22; transitions: 52; bytes: 62775; alphabet size: 26
bias: (pref: ""; accpt: false; temp: 0.000) TokenSet: 20/35000; ⟨0⟩ ⟨1⟩ ⟨2⟩ ⟨3⟩ ⟨4⟩ ⟨5⟩ ⟨6⟩ ⟨7⟩ ⟨8⟩ ⟨9⟩ ⟨1⟩ ⟨0⟩ ⟨2⟩ ⟨9⟩ ⟨3⟩ ⟨5⟩ ⟨4⟩ ⟨8⟩ ⟨6⟩ ⟨7⟩
thread 'integer_multipleof::test_value_1__3' panicked at sample_parser\tests\common_lark_utils\mod.rs:162:13:
Unexpected token: ⟨-⟩ at token index 0
Consider
which passes.
Start changing the
test_valueto negative numbers, and get: