From 8f4160310193ad3a7415cd168bb9aceca9093e3a Mon Sep 17 00:00:00 2001 From: Skgland Date: Thu, 11 Mar 2021 01:19:17 +0100 Subject: [PATCH] add more tests for some of the recently closed issues --- tests-pl/issue812-singleton-warning.pl | 4 + tests-pl/issue820-goals.pl | 3 + tests-pl/issue831-call0.pl | 1 + tests-pl/issue839-op3.pl | 1 + tests-pl/issue841-occure-check.pl | 3 + tests-pl/issue852-throw_e.pl | 1 + tests/scryer/issues.rs | 163 +++++++++++++++++++++++++ tests/scryer/main.rs | 1 + 8 files changed, 177 insertions(+) create mode 100644 tests-pl/issue812-singleton-warning.pl create mode 100644 tests-pl/issue820-goals.pl create mode 100644 tests-pl/issue831-call0.pl create mode 100644 tests-pl/issue839-op3.pl create mode 100644 tests-pl/issue841-occure-check.pl create mode 100644 tests-pl/issue852-throw_e.pl create mode 100644 tests/scryer/issues.rs diff --git a/tests-pl/issue812-singleton-warning.pl b/tests-pl/issue812-singleton-warning.pl new file mode 100644 index 00000000..9c8673b9 --- /dev/null +++ b/tests-pl/issue812-singleton-warning.pl @@ -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 index 00000000..fc94b92e --- /dev/null +++ b/tests-pl/issue820-goals.pl @@ -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 index 00000000..5c01fdf7 --- /dev/null +++ b/tests-pl/issue831-call0.pl @@ -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 index 00000000..3f362cf6 --- /dev/null +++ b/tests-pl/issue839-op3.pl @@ -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 index 00000000..c5c3d22c --- /dev/null +++ b/tests-pl/issue841-occure-check.pl @@ -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 index 00000000..ff1119ce --- /dev/null +++ b/tests-pl/issue852-throw_e.pl @@ -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 index 00000000..857d8e82 --- /dev/null +++ b/tests/scryer/issues.rs @@ -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", + ); +} diff --git a/tests/scryer/main.rs b/tests/scryer/main.rs index 649a44b4..1b3ada5f 100644 --- a/tests/scryer/main.rs +++ b/tests/scryer/main.rs @@ -1,3 +1,4 @@ mod helper; +mod issues; mod src_tests; -- 2.54.0