Fix handling of optval.
This commit is contained in:
parent
0edf5620a2
commit
606bab9e6d
@ -574,11 +574,11 @@ fn compare_object_tree<'e, 's, 'w>(
|
|||||||
.expect("If-statement proves this will be Some.");
|
.expect("If-statement proves this will be Some.");
|
||||||
result.extend(compare_json_value(source, emacs_val, wasm_val)?)?;
|
result.extend(compare_json_value(source, emacs_val, wasm_val)?)?;
|
||||||
} else {
|
} else {
|
||||||
// If optval is not null, then the emacs array should contain 3 values, the optval, a dot, and the val.
|
// If optval is not null, then the emacs array should contain a list, the first child of which is a list for optval, and all other entries to the outer list are the val.
|
||||||
if emacs_attribute.len() != 3 {
|
if emacs_attribute.len() < 2 {
|
||||||
result.status.push(WasmDiffStatus::Bad(
|
result.status.push(WasmDiffStatus::Bad(
|
||||||
format!(
|
format!(
|
||||||
"Emacs middle layer in object tree should have a length of 3. Emacs=({emacs:?}) Wasm=({wasm:?}).",
|
"Emacs middle layer in object tree should have a length of at least 2. Emacs=({emacs:?}) Wasm=({wasm:?}).",
|
||||||
emacs = emacs_attribute,
|
emacs = emacs_attribute,
|
||||||
wasm = wasm_attribute
|
wasm = wasm_attribute
|
||||||
)
|
)
|
||||||
@ -586,20 +586,27 @@ fn compare_object_tree<'e, 's, 'w>(
|
|||||||
));
|
));
|
||||||
return Ok(result);
|
return Ok(result);
|
||||||
}
|
}
|
||||||
let emacs_optval = emacs_attribute
|
let emacs_optval = emacs_attribute.iter().skip(1);
|
||||||
.first()
|
|
||||||
.expect("If-statement proves this will be Some.");
|
|
||||||
let wasm_optval = wasm_attribute
|
let wasm_optval = wasm_attribute
|
||||||
.first()
|
.first()
|
||||||
.expect("If-statement proves this will be Some.");
|
.expect("If-statement proves this will be Some.")
|
||||||
|
.as_array()
|
||||||
|
.ok_or("first value in wasm object tree should be a list.")?;
|
||||||
let emacs_val = emacs_attribute
|
let emacs_val = emacs_attribute
|
||||||
.get(2)
|
.first()
|
||||||
.expect("If-statement proves this will be Some.");
|
.ok_or("If-statement proves this will be Some.")?
|
||||||
|
.as_list()?;
|
||||||
let wasm_val = wasm_attribute
|
let wasm_val = wasm_attribute
|
||||||
.get(1)
|
.get(1)
|
||||||
.expect("If-statement proves this will be Some.");
|
.expect("If-statement proves this will be Some.")
|
||||||
result.extend(compare_json_value(source, emacs_optval, wasm_optval)?)?;
|
.as_array()
|
||||||
result.extend(compare_json_value(source, emacs_val, wasm_val)?)?;
|
.ok_or("2nd value in wasm object tree should be a list.")?;
|
||||||
|
result.extend(wasm_compare_list(source, emacs_optval, wasm_optval.iter())?)?;
|
||||||
|
result.extend(wasm_compare_list(
|
||||||
|
source,
|
||||||
|
emacs_val.iter(),
|
||||||
|
wasm_val.iter(),
|
||||||
|
)?)?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user