Commit 662eb51537067655258c6cc51b6d033a89b988ca

Thomas de Grivel 2023-02-11T17:30:21

env_test

diff --git a/test/env_test.c b/test/env_test.c
new file mode 100644
index 0000000..bf6ff6d
--- /dev/null
+++ b/test/env_test.c
@@ -0,0 +1,57 @@
+/* c3
+ * Copyright 2022,2023 kmx.io <contact@kmx.io>
+ *
+ * Permission is hereby granted to use this software excepted
+ * on Apple computers granted the above copyright notice and
+ * this permission paragraph are included in all copies and
+ * substantial portions of this software.
+ *
+ * THIS SOFTWARE IS PROVIDED "AS-IS" WITHOUT ANY GUARANTEE OF
+ * PURPOSE AND PERFORMANCE. IN NO EVENT WHATSOEVER SHALL THE
+ * AUTHOR BE CONSIDERED LIABLE FOR THE USE AND PERFORMANCE OF
+ * THIS SOFTWARE.
+ */
+#include "../libc3/env.h"
+#include "test.h"
+
+void env_test ();
+void env_test_eval_equal_tag ();
+void env_test_init_clean ();
+
+void env_test ()
+{
+  env_test_init_clean();
+  env_test_eval_equal_tag();
+}
+
+void env_test_eval_equal_tag ()
+{
+  s_env env;
+  s_frame frame;
+  s_tag x;
+  s_tag y;
+  env_init(&env);
+  env->frame = frame_init(&frame, env->frame);
+  test_context("x = 1");
+  TEST_ASSERT(env_eval_equal_tag(&env, tag_init_1(&x, "x"),
+                                 tag_init_1(&y, "1")));
+  TEST_ASSERT(frame_get(&frame, x.data.sym));
+  env_clean(&env);
+  env_init(&env);
+  env->frame = frame_init(&frame, env->frame);
+  test_context("x = 1");
+  TEST_ASSERT(env_eval_equal_tag(&env, tag_init_1(&x, "x"),
+                                 tag_init_1(&y, "[1, 2]")));
+  TEST_ASSERT(frame_get(&frame, x.data.sym));
+  env_clean(&env);
+  test_context(NULL);
+}
+
+void env_test_init_clean ()
+{
+  s_env env;
+  env_init(&env);
+  test_ok();
+  env_clean(&env);
+  test_ok();
+}
diff --git a/test/libc3_test.c b/test/libc3_test.c
index 05d1b59..dc95a84 100644
--- a/test/libc3_test.c
+++ b/test/libc3_test.c
@@ -22,6 +22,7 @@ void buf_test ();
 void call_test ();
 void character_test ();
 void compare_test ();
+void env_test ();
 void fact_test ();
 void facts_test ();
 void facts_cursor_test ();
@@ -129,6 +130,10 @@ int main (int argc, char **argv)
     printf("\nfacts_with\n");
     facts_with_test();
   }
+  if (test_target("env")) {
+    printf("\nenv\n");
+    env_test();
+  }
   test_summary();
   test_clean();
   c3_clean(NULL);
diff --git a/test/sources.mk b/test/sources.mk
index a84910e..b7c4c15 100644
--- a/test/sources.mk
+++ b/test/sources.mk
@@ -1,2 +1,29 @@
 # sources.mk generated by update_sources
-SOURCES = bool_test.c buf_file_test.c buf_inspect_test.c buf_parse_test.c buf_test.c call_test.c character_test.c compare_test.c fact_test.c facts_cursor_test.c facts_test.c facts_with_test.c hash_test.c ident_test.c libc3_test.c list_test.c set__fact_test.c set__tag_test.c skiplist__fact_test.c str_test.c sym_test.c tag_test.c test.c tuple_test.c types_test.c 
+SOURCES = \
+	bool_test.c \
+	buf_file_test.c \
+	buf_inspect_test.c \
+	buf_parse_test.c \
+	buf_test.c \
+	call_test.c \
+	character_test.c \
+	compare_test.c \
+	env_test.c \
+	fact_test.c \
+	facts_cursor_test.c \
+	facts_test.c \
+	facts_with_test.c \
+	hash_test.c \
+	ident_test.c \
+	libc3_test.c \
+	list_test.c \
+	set__fact_test.c \
+	set__tag_test.c \
+	skiplist__fact_test.c \
+	str_test.c \
+	sym_test.c \
+	tag_test.c \
+	test.c \
+	tuple_test.c \
+	types_test.c \
+
diff --git a/test/sources.sh b/test/sources.sh
index 565d8be..f28d2a6 100644
--- a/test/sources.sh
+++ b/test/sources.sh
@@ -1,2 +1,2 @@
 # sources.sh generated by update_sources
-SOURCES='bool_test.c buf_file_test.c buf_inspect_test.c buf_parse_test.c buf_test.c call_test.c character_test.c compare_test.c fact_test.c facts_cursor_test.c facts_test.c facts_with_test.c hash_test.c ident_test.c libc3_test.c list_test.c set__fact_test.c set__tag_test.c skiplist__fact_test.c str_test.c sym_test.c tag_test.c test.c tuple_test.c types_test.c '
+SOURCES='bool_test.c buf_file_test.c buf_inspect_test.c buf_parse_test.c buf_test.c call_test.c character_test.c compare_test.c env_test.c fact_test.c facts_cursor_test.c facts_test.c facts_with_test.c hash_test.c ident_test.c libc3_test.c list_test.c set__fact_test.c set__tag_test.c skiplist__fact_test.c str_test.c sym_test.c tag_test.c test.c tuple_test.c types_test.c '
diff --git a/test/update_sources b/test/update_sources
index 74c1c03..6c7b350 100755
--- a/test/update_sources
+++ b/test/update_sources
@@ -18,9 +18,7 @@ echo "# sources.mk generated by update_sources" > ${SOURCES_MK}
 echo "# sources.sh generated by update_sources" > ${SOURCES_SH}
 
 SOURCES="$(ls *.c)"
-SOURCES="$(echo "$SOURCES" | tr '\n' ' ')"
-echo "SOURCES = $SOURCES" >> ${SOURCES_MK}
-echo "SOURCES='$SOURCES'" >> ${SOURCES_SH}
+sources SOURCES "$SOURCES"
 
 update_sources_mk
 update_sources_sh