Add remove/insert to arrays and maps.

This commit is contained in:
Stephen Chung
2020-04-10 21:59:29 +08:00
parent 81894e52cb
commit c1b16b1a35
4 changed files with 127 additions and 69 deletions

View File

@@ -33,6 +33,16 @@ fn test_map_indexing() -> Result<(), EvalAltResult> {
assert!(engine.eval::<bool>("let y = #{a: 1, b: 2, c: 3}; 'b' in y")?);
assert!(!engine.eval::<bool>(r#"let y = #{a: 1, b: 2, c: 3}; "z" in y"#)?);
assert_eq!(
engine.eval::<INT>(
r#"
let x = #{a: 1, b: 2, c: 3};
let c = x.remove("c");
x.len() + c
"#
)?,
5
);
assert_eq!(
engine.eval::<INT>(
r"