Implement every statement (#4)

Signed-off-by: Anand Krishnamoorthi <anakrish@microsoft.com>
This commit is contained in:
Anand Krishnamoorthi
2023-02-20 06:30:40 +05:30
parent 2a1924efa5
commit 351483d100
6 changed files with 238 additions and 45 deletions

View File

@@ -1,5 +1,5 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
# Copyright (c) Microsoft Corporation. Licensed under the MIT
# License.
cases:
- note: basic
@@ -28,7 +28,7 @@ cases:
stmts:
- literal:
every:
key: x
value: x
domain:
array:
- number: 2

View File

@@ -525,19 +525,19 @@ fn match_literal(l: &Literal, v: &Value) -> Result<()> {
query,
} => {
match_span_opt(span, &v["every"]["span"])?;
match_span(key, &v["every"]["key"])?;
match value {
Some(s) => match_span(s, &v["every"]["value"])?,
match_span(value, &v["every"]["value"])?;
match key {
Some(s) => match_span(s, &v["every"]["key"])?,
None => {
my_assert_eq!(
&Value::Undefined,
&v["value"],
&v["key"],
"{}",
span.source.message(
span.line,
span.col,
"mismatch-error",
"could not match `value``"
"could not match `key``"
)
);
}