Commit e18e012b2658664d9071dbe072675ec3d259ac05

Thomas de Grivel 2023-11-13T16:35:44

map tests

diff --git a/libc3/env.c b/libc3/env.c
index 5cf90e5..5e54ee0 100644
--- a/libc3/env.c
+++ b/libc3/env.c
@@ -562,6 +562,7 @@ bool env_eval_map (s_env *env, const s_map *map, s_tag *dest)
       goto ko;
     i++;
   }
+  map_sort(&tmp);
   dest->type = TAG_MAP;
   dest->data.map = tmp;
   return true;
diff --git a/test/ic3/map.in b/test/ic3/map.in
new file mode 100644
index 0000000..e51ec0a
--- /dev/null
+++ b/test/ic3/map.in
@@ -0,0 +1,32 @@
+quote %{}
+%{}
+quote %{"a": 1}
+%{a: 1}
+quote %{"a": 1, "b": 2}
+%{a: 1, b: 2}
+quote %{"a": 1, "b": 2, "c": 3}
+%{a: 1, b: 2, c: 3}
+quote %{"c": 1, "b": 2, "a": 3}
+%{a: 3, b: 2, c: 1}
+quote %{"a" => 1}
+%{"a" => 1}
+quote %{"a" => 1, "b" => 2}
+%{"a" => 1, "b" => 2}
+quote %{"a" => 1, "b" => 2, "c" => 3}
+%{"a" => 1, "b" => 2, "c" => 3}
+quote %{"c" => 1, "b" => 2, "a" => 3}
+%{"c" => 1, "b" => 2, "a" => 3}
+quote %{1 => 1}
+%{1 => 1}
+quote %{1 => 1, 2 => 2}
+%{1 => 1, 2 => 2}
+quote %{1 => 1, 2 => 2, 3 => 3}
+%{1 => 1, 2 => 2, 3 => 3}
+quote %{1 + 1 => 2 + 2}
+%{2 => 4}
+quote %{1 + 1 => 2 + 2, 3 + 3 => 4 + 4}
+%{2 => 4, 6 => 8}
+quote %{1 + 1 => 2 + 2, 3 + 3 => 4 + 4, 5 + 5 => 6 + 6}
+%{2 => 4, 6 => 8, 10 => 12}
+quote %{6 + 6 => 1 + 1, 5 + 5 => 2 + 2, 4 + 4 => 3 + 3}
+%{8 => 6, 10 => 4, 12 => 2}
diff --git a/test/ic3/map.out.expected b/test/ic3/map.out.expected
new file mode 100644
index 0000000..d3808f3
--- /dev/null
+++ b/test/ic3/map.out.expected
@@ -0,0 +1,34 @@
+%{}
+%{}
+%{a: 1}
+%{a: 1}
+%{a: 1, b: 2}
+%{a: 1, b: 2}
+%{a: 1, b: 2, c: 3}
+%{a: 1, b: 2, c: 3}
+%{a: 3, b: 2, c: 1}
+%{a: 3, b: 2, c: 1}
+%{"a" => 1}
+%{"a" => 1}
+%{"a" => 1, "b" => 2}
+%{"a" => 1, "b" => 2}
+%{"a" => 1, "b" => 2, "c" => 3}
+%{"a" => 1, "b" => 2, "c" => 3}
+%{"a" => 3, "b" => 2, "c" => 1}
+%{"a" => 3, "b" => 2, "c" => 1}
+%{1 => 1}
+%{1 => 1}
+%{1 => 1, 2 => 2}
+%{1 => 1, 2 => 2}
+%{1 => 1, 2 => 2, 3 => 3}
+%{1 => 1, 2 => 2, 3 => 3}
+%{1 => 3, 2 => 2, 3 => 1}
+%{1 => 3, 2 => 2, 3 => 1}
+%{1 + 1 => 2 + 2}
+%{2 => 4}
+%{1 + 1 => 2 + 2, 3 + 3 => 4 + 4}
+%{2 => 4, 6 => 8}
+%{1 + 1 => 2 + 2, 3 + 3 => 4 + 4, 5 + 5 => 6 + 6}
+%{2 => 4, 6 => 8, 10 => 12}
+%{6 + 6 => 1 + 1, 5 + 5 => 2 + 2, 4 + 4 => 3 + 3}
+%{8 => 6, 10 => 4, 12 => 2}
diff --git a/test/ic3/map.ret.expected b/test/ic3/map.ret.expected
new file mode 100644
index 0000000..573541a
--- /dev/null
+++ b/test/ic3/map.ret.expected
@@ -0,0 +1 @@
+0