]> Repositorios git - scryer-prolog.git/commitdiff
add more tests
authorSkgland <[email protected]>
Thu, 11 Mar 2021 00:19:17 +0000 (01:19 +0100)
committerSkgland <[email protected]>
Thu, 11 Mar 2021 00:52:22 +0000 (01:52 +0100)
for some of the recently closed issues

tests-pl/issue812-singleton-warning.pl [new file with mode: 0644]
tests-pl/issue820-goals.pl [new file with mode: 0644]
tests-pl/issue831-call0.pl [new file with mode: 0644]
tests-pl/issue839-op3.pl [new file with mode: 0644]
tests-pl/issue841-occure-check.pl [new file with mode: 0644]
tests-pl/issue852-throw_e.pl [new file with mode: 0644]
tests/scryer/issues.rs [new file with mode: 0644]
tests/scryer/main.rs

diff --git a/tests-pl/issue812-singleton-warning.pl b/tests-pl/issue812-singleton-warning.pl
new file mode 100644 (file)
index 0000000..9c8673b
--- /dev/null
@@ -0,0 +1,4 @@
+% hello
+% line!
+
+a :- b(X).
\ No newline at end of file
diff --git a/tests-pl/issue820-goals.pl b/tests-pl/issue820-goals.pl
new file mode 100644 (file)
index 0000000..fc94b92
--- /dev/null
@@ -0,0 +1,3 @@
+test :- write(world), nl.
+
+:- initialization(write(hello)).
\ No newline at end of file
diff --git a/tests-pl/issue831-call0.pl b/tests-pl/issue831-call0.pl
new file mode 100644 (file)
index 0000000..5c01fdf
--- /dev/null
@@ -0,0 +1 @@
+:- initialization(call).
\ No newline at end of file
diff --git a/tests-pl/issue839-op3.pl b/tests-pl/issue839-op3.pl
new file mode 100644 (file)
index 0000000..3f362cf
--- /dev/null
@@ -0,0 +1 @@
+:- op(900, fy, [$,@]).
\ No newline at end of file
diff --git a/tests-pl/issue841-occure-check.pl b/tests-pl/issue841-occure-check.pl
new file mode 100644 (file)
index 0000000..c5c3d22
--- /dev/null
@@ -0,0 +1,3 @@
+:- set_prolog_flag(occurs_check, true).
+
+f(X, g(X)).
\ No newline at end of file
diff --git a/tests-pl/issue852-throw_e.pl b/tests-pl/issue852-throw_e.pl
new file mode 100644 (file)
index 0000000..ff1119c
--- /dev/null
@@ -0,0 +1 @@
+:- initialization(throw(e)).
\ No newline at end of file
diff --git a/tests/scryer/issues.rs b/tests/scryer/issues.rs
new file mode 100644 (file)
index 0000000..857d8e8
--- /dev/null
@@ -0,0 +1,163 @@
+use crate::helper::{load_module_test, run_top_level_test_no_args, run_top_level_test_with_args};
+
+// issue #857
+#[test]
+fn display_constraints() {
+    run_top_level_test_no_args(
+        "\
+        X = 1.\n\
+        use_module(library(dif)).\n\
+        X = 1.\n\
+        dif(X,1).\n",
+        "   \
+        X = 1.\n   \
+        true.\n   \
+        X = 1.\n   \
+        dif:dif(X,1).\n\
+        ",
+    );
+}
+
+// issue #852
+#[test]
+fn do_not_duplicate_path_components() {
+    run_top_level_test_no_args(
+        "\
+            ['tests-pl/issue852-throw_e.pl'].\n\
+            ['tests-pl/issue852-throw_e.pl'].\n\
+            ",
+        "\
+        caught: e\n\
+        false.\n\
+        Warning: overwriting $initialization_goals/1\n\
+        caught: e\n\
+        false.\n\
+        ",
+    );
+}
+
+// issue #844
+#[test]
+fn handle_residual_goal() {
+    run_top_level_test_no_args(
+        "\
+        use_module(library(dif)).\n\
+        use_module(library(atts)).\n\
+        -X\\=X.\n\
+        -X=X.\n\
+        dif(-X,X).\n\
+        dif(-X,X), -X=X.\n\
+        call_residue_vars(dif(-X,X), Vars).\n\
+        set_prolog_flag(occurs_check, true).\n\
+        -X\\=X.\n\
+        dif(-X,X).\n\
+        ",
+        "   \
+        true.\n   \
+        true.\n\
+        false.\n   \
+        X = - X.\n   \
+        dif:dif(- X,X).\n\
+        false.\n   \
+        Vars = [X], dif:dif(- X,X).\n   \
+        true.\n   \
+        true.\n   \
+        true.\n\
+        ",
+    )
+}
+
+// issue #841
+#[test]
+fn occurs_check_flag() {
+    run_top_level_test_with_args(
+        &["tests-pl/issue841-occure-check.pl"],
+        "\
+            f(X, X).\n\
+            ",
+        "false.\n",
+    )
+}
+
+#[test]
+fn occurs_check_flag2() {
+    run_top_level_test_no_args(
+        "\
+            set_prolog_flag(occurs_check, true).\n\
+            X = -X.\n\
+            asserta(f(X,g(X))).\n\
+            f(X,X).\n\
+            X-X = X-g(X).
+            ",
+        "   \
+            true.\n\
+            false.\n   \
+            true.\n\
+            false.\n\
+            false.\n\
+            ",
+    )
+}
+
+// issue #839
+#[test]
+fn op3() {
+    run_top_level_test_with_args(&["tests-pl/issue839-op3.pl"], "", "")
+}
+
+// issue #820
+#[test]
+fn multiple_goals() {
+    run_top_level_test_with_args(
+        &["-g", "test", "-g", "halt", "tests-pl/issue820-goals.pl"],
+        "",
+        "helloworld\n",
+    );
+}
+
+// issue #820
+#[test]
+fn compound_goal() {
+    run_top_level_test_with_args(
+        &["-g", "test,halt", "tests-pl/issue820-goals.pl"],
+        "",
+        "helloworld\n",
+    )
+}
+
+// issue #815
+#[test]
+fn no_stutter() {
+    run_top_level_test_no_args("write(a), write(b), false.\n", "abfalse.\n")
+}
+
+// issue #812
+#[test]
+#[ignore] // FIXME: line is of by one, empty line not accounted for or starting to count at line 0?
+fn singleton_warning() {
+    run_top_level_test_no_args(
+        "['tests-pl/issue812-singleton-warning.pl'].",
+        "\
+        Warning: singleton variables X at line 4 of issue812-singleton-warning.pl\n   \
+        true.\n\
+        ",
+    );
+}
+
+// issue #807
+#[test]
+fn ignored_constraint() {
+    run_top_level_test_no_args(
+        "use_module(library(freeze)), freeze(X,false), X \\=a.",
+        "   freeze:freeze(X,user:false).\n",
+    );
+}
+
+// issue #831
+#[test]
+fn call_0() {
+    load_module_test(
+        "tests-pl/issue831-call0.pl",
+        "caught: error(existence_error(procedure,call/0),call/0)\n",
+    );
+}
index 649a44b4aec1962ba35d9669c8623ec585d4256b..1b3ada5feb7a286aefbe254e3ab5f8d3ad5d56d4 100644 (file)
@@ -1,3 +1,4 @@
 mod helper;
 
+mod issues;
 mod src_tests;