File-oriented testing
inspired by #2191 but for the `run_top_level_test_with_args`s and `run_top_level_test_no_args instead of the `load_module_test`s
This commit is contained in:
0
tests/scryer/cli/issues/compound_goal.stderr
Normal file
0
tests/scryer/cli/issues/compound_goal.stderr
Normal file
1
tests/scryer/cli/issues/compound_goal.stdout
Normal file
1
tests/scryer/cli/issues/compound_goal.stdout
Normal file
@@ -0,0 +1 @@
|
||||
helloworld
|
||||
3
tests/scryer/cli/issues/compound_goal.toml
Normal file
3
tests/scryer/cli/issues/compound_goal.toml
Normal file
@@ -0,0 +1,3 @@
|
||||
# issue 820
|
||||
args = ["-f", "--no-add-history", "-g", "test,halt", "tests-pl/issue820-goals.pl"]
|
||||
binary = true
|
||||
0
tests/scryer/cli/issues/display_constraints.stderr
Normal file
0
tests/scryer/cli/issues/display_constraints.stderr
Normal file
5
tests/scryer/cli/issues/display_constraints.stdin
Normal file
5
tests/scryer/cli/issues/display_constraints.stdin
Normal file
@@ -0,0 +1,5 @@
|
||||
X = 1.
|
||||
use_module(library(dif)).
|
||||
X = 1.
|
||||
dif(X,1).
|
||||
halt.
|
||||
4
tests/scryer/cli/issues/display_constraints.stdout
Normal file
4
tests/scryer/cli/issues/display_constraints.stdout
Normal file
@@ -0,0 +1,4 @@
|
||||
X = 1.
|
||||
true.
|
||||
X = 1.
|
||||
dif:dif(X,1).
|
||||
3
tests/scryer/cli/issues/display_constraints.toml
Normal file
3
tests/scryer/cli/issues/display_constraints.toml
Normal file
@@ -0,0 +1,3 @@
|
||||
# issue 857
|
||||
args = ["-f", "--no-add-history"]
|
||||
binary = true
|
||||
@@ -0,0 +1,3 @@
|
||||
['tests-pl/issue852-throw_e.pl'].
|
||||
['tests-pl/issue852-throw_e.pl'].
|
||||
halt.
|
||||
@@ -0,0 +1,2 @@
|
||||
throw(e).
|
||||
throw(e).
|
||||
@@ -0,0 +1,3 @@
|
||||
# issue 852
|
||||
args = ["-f", "--no-add-history"]
|
||||
binary = true
|
||||
0
tests/scryer/cli/issues/handle_residual_goal.stderr
Normal file
0
tests/scryer/cli/issues/handle_residual_goal.stderr
Normal file
11
tests/scryer/cli/issues/handle_residual_goal.stdin
Normal file
11
tests/scryer/cli/issues/handle_residual_goal.stdin
Normal file
@@ -0,0 +1,11 @@
|
||||
use_module(library(dif)).
|
||||
use_module(library(atts)).
|
||||
-X\=X.
|
||||
-X=X.
|
||||
dif(-X,X).
|
||||
dif(-X,X), -X=X.
|
||||
call_residue_vars(dif(-X,X), Vars).
|
||||
set_prolog_flag(occurs_check, true).
|
||||
-X\=X.
|
||||
dif(-X,X).
|
||||
halt.
|
||||
10
tests/scryer/cli/issues/handle_residual_goal.stdout
Normal file
10
tests/scryer/cli/issues/handle_residual_goal.stdout
Normal file
@@ -0,0 +1,10 @@
|
||||
true.
|
||||
true.
|
||||
false.
|
||||
X = -X.
|
||||
dif:dif(-X,X).
|
||||
false.
|
||||
Vars = [X], dif:dif(-X,X).
|
||||
true.
|
||||
true.
|
||||
true.
|
||||
3
tests/scryer/cli/issues/handle_residual_goal.toml
Normal file
3
tests/scryer/cli/issues/handle_residual_goal.toml
Normal file
@@ -0,0 +1,3 @@
|
||||
# issue 844
|
||||
args = ["-f", "--no-add-history"]
|
||||
binary = true
|
||||
0
tests/scryer/cli/issues/ignored_constraint.stderr
Normal file
0
tests/scryer/cli/issues/ignored_constraint.stderr
Normal file
2
tests/scryer/cli/issues/ignored_constraint.stdin
Normal file
2
tests/scryer/cli/issues/ignored_constraint.stdin
Normal file
@@ -0,0 +1,2 @@
|
||||
use_module(library(freeze)), freeze(X,false), X \=a.
|
||||
halt.
|
||||
1
tests/scryer/cli/issues/ignored_constraint.stdout
Normal file
1
tests/scryer/cli/issues/ignored_constraint.stdout
Normal file
@@ -0,0 +1 @@
|
||||
freeze:freeze(X,false).
|
||||
3
tests/scryer/cli/issues/ignored_constraint.toml
Normal file
3
tests/scryer/cli/issues/ignored_constraint.toml
Normal file
@@ -0,0 +1,3 @@
|
||||
# issue 807
|
||||
args = ["-f", "--no-add-history"]
|
||||
binary = true
|
||||
0
tests/scryer/cli/issues/multiple_goals.stderr
Normal file
0
tests/scryer/cli/issues/multiple_goals.stderr
Normal file
1
tests/scryer/cli/issues/multiple_goals.stdout
Normal file
1
tests/scryer/cli/issues/multiple_goals.stdout
Normal file
@@ -0,0 +1 @@
|
||||
helloworld
|
||||
3
tests/scryer/cli/issues/multiple_goals.toml
Normal file
3
tests/scryer/cli/issues/multiple_goals.toml
Normal file
@@ -0,0 +1,3 @@
|
||||
# issue 820
|
||||
args = ["-f", "--no-add-history", "-g", "test", "-g", "halt", "tests-pl/issue820-goals.pl"]
|
||||
binary = true
|
||||
0
tests/scryer/cli/issues/no_stutter.stderr
Normal file
0
tests/scryer/cli/issues/no_stutter.stderr
Normal file
2
tests/scryer/cli/issues/no_stutter.stdin
Normal file
2
tests/scryer/cli/issues/no_stutter.stdin
Normal file
@@ -0,0 +1,2 @@
|
||||
write(a), write(b), false.
|
||||
halt.
|
||||
1
tests/scryer/cli/issues/no_stutter.stdout
Normal file
1
tests/scryer/cli/issues/no_stutter.stdout
Normal file
@@ -0,0 +1 @@
|
||||
ab false.
|
||||
3
tests/scryer/cli/issues/no_stutter.toml
Normal file
3
tests/scryer/cli/issues/no_stutter.toml
Normal file
@@ -0,0 +1,3 @@
|
||||
# issue 815
|
||||
args = ["-f", "--no-add-history"]
|
||||
binary = true
|
||||
0
tests/scryer/cli/issues/occurs_check_flag.stderr
Normal file
0
tests/scryer/cli/issues/occurs_check_flag.stderr
Normal file
2
tests/scryer/cli/issues/occurs_check_flag.stdin
Normal file
2
tests/scryer/cli/issues/occurs_check_flag.stdin
Normal file
@@ -0,0 +1,2 @@
|
||||
f(X, X).
|
||||
halt.
|
||||
1
tests/scryer/cli/issues/occurs_check_flag.stdout
Normal file
1
tests/scryer/cli/issues/occurs_check_flag.stdout
Normal file
@@ -0,0 +1 @@
|
||||
false.
|
||||
3
tests/scryer/cli/issues/occurs_check_flag.toml
Normal file
3
tests/scryer/cli/issues/occurs_check_flag.toml
Normal file
@@ -0,0 +1,3 @@
|
||||
# issue 841
|
||||
args = ["-f", "--no-add-history", "tests-pl/issue841-occurs-check.pl"]
|
||||
binary = true
|
||||
0
tests/scryer/cli/issues/occurs_check_flag2.stderr
Normal file
0
tests/scryer/cli/issues/occurs_check_flag2.stderr
Normal file
6
tests/scryer/cli/issues/occurs_check_flag2.stdin
Normal file
6
tests/scryer/cli/issues/occurs_check_flag2.stdin
Normal file
@@ -0,0 +1,6 @@
|
||||
set_prolog_flag(occurs_check, true).
|
||||
X = -X.
|
||||
asserta(f(X,g(X))).
|
||||
f(X,X).
|
||||
X-X = X-g(X).
|
||||
halt.
|
||||
5
tests/scryer/cli/issues/occurs_check_flag2.stdout
Normal file
5
tests/scryer/cli/issues/occurs_check_flag2.stdout
Normal file
@@ -0,0 +1,5 @@
|
||||
true.
|
||||
false.
|
||||
true.
|
||||
false.
|
||||
false.
|
||||
3
tests/scryer/cli/issues/occurs_check_flag2.toml
Normal file
3
tests/scryer/cli/issues/occurs_check_flag2.toml
Normal file
@@ -0,0 +1,3 @@
|
||||
# issue 841
|
||||
args = ["-f", "--no-add-history"]
|
||||
binary = true
|
||||
0
tests/scryer/cli/issues/op3.stderr
Normal file
0
tests/scryer/cli/issues/op3.stderr
Normal file
0
tests/scryer/cli/issues/op3.stdout
Normal file
0
tests/scryer/cli/issues/op3.stdout
Normal file
3
tests/scryer/cli/issues/op3.toml
Normal file
3
tests/scryer/cli/issues/op3.toml
Normal file
@@ -0,0 +1,3 @@
|
||||
# issue 839
|
||||
args = ["-f", "--no-add-history", "tests-pl/issue839-op3.pl", "-g", "halt"]
|
||||
binary = true
|
||||
0
tests/scryer/cli/issues/singleton_warning.stderr
Normal file
0
tests/scryer/cli/issues/singleton_warning.stderr
Normal file
2
tests/scryer/cli/issues/singleton_warning.stdin
Normal file
2
tests/scryer/cli/issues/singleton_warning.stdin
Normal file
@@ -0,0 +1,2 @@
|
||||
['tests-pl/issue812-singleton-warning.pl'].
|
||||
halt.
|
||||
2
tests/scryer/cli/issues/singleton_warning.stdout
Normal file
2
tests/scryer/cli/issues/singleton_warning.stdout
Normal file
@@ -0,0 +1,2 @@
|
||||
Warning: singleton variables X at line 4 of issue812-singleton-warning.pl
|
||||
true.
|
||||
3
tests/scryer/cli/issues/singleton_warning.toml
Normal file
3
tests/scryer/cli/issues/singleton_warning.toml
Normal file
@@ -0,0 +1,3 @@
|
||||
# issue 812
|
||||
args = ["-f", "--no-add-history"]
|
||||
binary = true
|
||||
1
tests/scryer/cli/src_tests/acyclic_term_tests.stdout
Normal file
1
tests/scryer/cli/src_tests/acyclic_term_tests.stdout
Normal file
@@ -0,0 +1 @@
|
||||
All tests passed
|
||||
2
tests/scryer/cli/src_tests/acyclic_term_tests.toml
Normal file
2
tests/scryer/cli/src_tests/acyclic_term_tests.toml
Normal file
@@ -0,0 +1,2 @@
|
||||
args = ["-f", "--no-add-history", "src/tests/acyclic_term.pl", "-f", "-g", "main_quiet"]
|
||||
binary = true
|
||||
0
tests/scryer/cli/src_tests/dif_tests.stderr
Normal file
0
tests/scryer/cli/src_tests/dif_tests.stderr
Normal file
1
tests/scryer/cli/src_tests/dif_tests.stdout
Normal file
1
tests/scryer/cli/src_tests/dif_tests.stdout
Normal file
@@ -0,0 +1 @@
|
||||
All tests passed
|
||||
2
tests/scryer/cli/src_tests/dif_tests.toml
Normal file
2
tests/scryer/cli/src_tests/dif_tests.toml
Normal file
@@ -0,0 +1,2 @@
|
||||
args = ["-f", "--no-add-history", "src/tests/dif.pl", "-f", "-g", "main_quiet"]
|
||||
binary = true
|
||||
0
tests/scryer/cli/src_tests/ground_tests.stderr
Normal file
0
tests/scryer/cli/src_tests/ground_tests.stderr
Normal file
1
tests/scryer/cli/src_tests/ground_tests.stdout
Normal file
1
tests/scryer/cli/src_tests/ground_tests.stdout
Normal file
@@ -0,0 +1 @@
|
||||
All tests passed
|
||||
2
tests/scryer/cli/src_tests/ground_tests.toml
Normal file
2
tests/scryer/cli/src_tests/ground_tests.toml
Normal file
@@ -0,0 +1,2 @@
|
||||
args = ["-f", "--no-add-history", "src/tests/ground.pl", "-f", "-g", "main_quiet"]
|
||||
binary = true
|
||||
@@ -0,0 +1 @@
|
||||
1+21+31+2>A+B1+G1+2>41+2>B1+2>31+2>31+2>4ba
|
||||
@@ -0,0 +1,2 @@
|
||||
args = ["-f", "--no-add-history", "src/tests/setup_call_cleanup.pl", "-f", "-g", "halt"]
|
||||
binary = true
|
||||
1
tests/scryer/cli/src_tests/term_variables_tests.stdout
Normal file
1
tests/scryer/cli/src_tests/term_variables_tests.stdout
Normal file
@@ -0,0 +1 @@
|
||||
All tests passed
|
||||
2
tests/scryer/cli/src_tests/term_variables_tests.toml
Normal file
2
tests/scryer/cli/src_tests/term_variables_tests.toml
Normal file
@@ -0,0 +1,2 @@
|
||||
args = ["-f", "--no-add-history", "src/tests/term_variables.pl", "-f", "-g", "main_quiet"]
|
||||
binary = true
|
||||
@@ -37,17 +37,6 @@ pub(crate) fn load_module_test<T: Expectable>(file: &str, expected: T) {
|
||||
|
||||
pub const SCRYER_PROLOG: &str = "scryer-prolog";
|
||||
|
||||
pub fn run_top_level_test_no_args<
|
||||
S: Into<Vec<u8>>,
|
||||
O: assert_cmd::assert::IntoOutputPredicate<P>,
|
||||
P: predicates_core::Predicate<[u8]>,
|
||||
>(
|
||||
stdin: S,
|
||||
expected_stdout: O,
|
||||
) {
|
||||
run_top_level_test_with_args::<&[&str], _, _, _, _>(&[], stdin, expected_stdout)
|
||||
}
|
||||
|
||||
/// Test whether scryer-prolog
|
||||
/// produces the expected output when called with the supplied
|
||||
/// arguments and fed the supplied input
|
||||
|
||||
@@ -1,165 +1,6 @@
|
||||
use crate::helper::{load_module_test, run_top_level_test_no_args, run_top_level_test_with_args};
|
||||
use crate::helper::load_module_test;
|
||||
use serial_test::serial;
|
||||
|
||||
// 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
|
||||
halt.\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\
|
||||
halt.\n\
|
||||
",
|
||||
" throw(e).\n throw(e).\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\
|
||||
halt.\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-occurs-check.pl"],
|
||||
"\
|
||||
f(X, X).\n\
|
||||
halt.\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).\n\
|
||||
halt.\n\
|
||||
",
|
||||
" \
|
||||
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", "-g", "halt"], "", "")
|
||||
}
|
||||
|
||||
// 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\
|
||||
halt.\n\
|
||||
",
|
||||
"ab false.\n",
|
||||
)
|
||||
}
|
||||
|
||||
/*
|
||||
// issue #812
|
||||
#[test] // FIXME: the line number is of by one (should be 4), 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'].\n\
|
||||
halt.\n",
|
||||
"\
|
||||
Warning: singleton variables X at line 3 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.\n\
|
||||
halt.",
|
||||
" freeze:freeze(X,false).\n",
|
||||
);
|
||||
}
|
||||
|
||||
// issue #831
|
||||
#[serial]
|
||||
|
||||
@@ -1,3 +1,17 @@
|
||||
mod helper;
|
||||
mod issues;
|
||||
mod src_tests;
|
||||
|
||||
/// to generate new reference output files into dump/ run `TRYCMD=dump cargo test -- cli_test`
|
||||
/// check that the output is as expected, then move them next to the .toml file
|
||||
///
|
||||
/// to re-generate reference output files run `TRYCMD=overwrite cargo test -- cli_test`
|
||||
/// then check that the changes are as expected e.g. by looking at the `git diff`
|
||||
#[test]
|
||||
fn cli_tests() {
|
||||
trycmd::TestCases::new()
|
||||
.default_bin_name("scryer-prolog")
|
||||
.case("tests/scryer/cli/issues/*.toml")
|
||||
.skip("tests/scryer/cli/issues/singleton_warning.toml") // wrong line number
|
||||
.case("tests/scryer/cli/src_tests/*.toml");
|
||||
}
|
||||
|
||||
@@ -55,15 +55,6 @@ fn setup_call_cleanup_load() {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn setup_call_cleanup_process() {
|
||||
run_top_level_test_with_args(
|
||||
["src/tests/setup_call_cleanup.pl", "-f", "-g", "halt"],
|
||||
"",
|
||||
"1+21+31+2>A+B1+G1+2>41+2>B1+2>31+2>31+2>4ba",
|
||||
);
|
||||
}
|
||||
|
||||
#[serial]
|
||||
#[test]
|
||||
fn clpz_load() {
|
||||
@@ -75,39 +66,3 @@ fn clpz_load() {
|
||||
fn iso_conformity_tests() {
|
||||
load_module_test("tests-pl/iso-conformity-tests.pl", "All tests passed");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn dif_tests() {
|
||||
run_top_level_test_with_args(
|
||||
["src/tests/dif.pl", "-f", "-g", "main_quiet"],
|
||||
"",
|
||||
"All tests passed",
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn ground_tests() {
|
||||
run_top_level_test_with_args(
|
||||
["src/tests/ground.pl", "-f", "-g", "main_quiet"],
|
||||
"",
|
||||
"All tests passed",
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn term_variables_tests() {
|
||||
run_top_level_test_with_args(
|
||||
["src/tests/term_variables.pl", "-f", "-g", "main_quiet"],
|
||||
"",
|
||||
"All tests passed",
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn acyclic_term_tests() {
|
||||
run_top_level_test_with_args(
|
||||
["src/tests/acyclic_term.pl", "-f", "-g", "main_quiet"],
|
||||
"",
|
||||
"All tests passed",
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user