Skip to content

Commit

Permalink
add nth_partial_strings_tests for bugs raised in #1827, #2381
Browse files Browse the repository at this point in the history
  • Loading branch information
mthom committed Apr 10, 2024
1 parent c2657cc commit 9837187
Show file tree
Hide file tree
Showing 4 changed files with 140 additions and 0 deletions.
137 changes: 137 additions & 0 deletions src/tests/nth_partial_strings.pl
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
/**/

:- module(nth_partial_strings_tests, []).

:- use_module(library(between)).
:- use_module(library(lists)).

:- use_module(test_framework).

test("nth_partial_string_tests#1827_1", (
L="ab",
findall([N,E], (between(0,2,N), nth0(N,[x|L],E)), S),
S = [[0,x],[1,a],[2,b]]
)).

test("nth_partial_string_tests#2381_1", (
G="AA",
G=[_|Gs],
G_=['A'|Gs],
write(G_),
nth0(1,G_,C),
char_code(C,N),
write(N),
nl
)).

test("nth_partial_string_tests#2382_2", (
G="AA",
G=[_|Gs],
G_=['A'|Gs],
findall([L,C],nth0(L,G_,C),S),
S=[[0,'A'],[1,'A']]
)).

test("nth_partial_string_tests#2382_3", (
G="AA",
G=[_|Gs],
G_=['A'|Gs],
nth0(1,G_,C),
C='A'
)).


test("nth_partial_string_tests#2382_4", (
G="XYZ",
G=[_|Gs],
G_=['A'|Gs],
nth0(2,G_,C),
C='Z'
)).

test("nth_partial_string_tests#2382_5", (
G="XYZ",
G=[_|Gs],
G_=['A'|Gs],
nth0(2,G_,C),
C='Z'
)).

test("nth_partial_string_tests#2382_6", (
G="XYZ",
G=[_,_|T],
nth0(0,T,C),
C='Z'
)).

test("nth_partial_string_tests#2382_7", (
G="XYZ",
G=[_,_|T],
nth0(L,T,C),
L=0,
!,
C='Z'
)).

test("nth_partial_string_tests#2382_8", (
G="XYZ",
G=[_,_|T],
L=0,
nth0(L,T,C),
C='Z'
)).

test("nth_partial_string_tests#2382_9", (
G="XYZ",
G=[_|T],
nth0(0,T,C),
C='Y'
)).

test("nth_partial_string_tests#2382_10", (
G="XYZ",
G=[_|T],
nth0(1,T,C),
C='Z'
)).

test("nth_partial_string_tests#2382_11", (
G="XYZ",
T=[G|G],
findall([L,C],nth0(L,T,C),S),
S=[[0, "XYZ"],[1,'X'],[2,'Y'],[3,'Z']]
)).

test("nth_partial_string_tests#2382_12", (
G="XYZ",
T=[G|G],
nth0(L,T,C),
L=3,
!,
C='Z'
)).

test("nth_partial_string_tests#2382_13", (
G="XYZ",
T=[G|G],
nth0(L,T,C),
L=3,
!,
C='Z'
)).

test("nth_partial_string_tests#2382_14", (
G="XYZ",
T=[G|G],
L=3,
nth0(L,T,C),
C='Z'
)).

test("nth_partial_string_tests#2382_15", (
G="XYZ",
T=[G|G],
L=2,
nth0(L,T,C),
C='Y'
)).
Empty file.
2 changes: 2 additions & 0 deletions tests/scryer/cli/src_tests/nth_partial_strings_tests.stdout
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[A,A]65
All tests passed
1 change: 1 addition & 0 deletions tests/scryer/cli/src_tests/nth_partial_strings_tests.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
args = ["-f", "--no-add-history", "src/tests/nth_partial_strings.pl", "-f", "-g", "use_module(library(nth_partial_strings_tests)),nth_partial_strings_tests:main_quiet(nth_partial_strings_tests)"]

0 comments on commit 9837187

Please sign in to comment.