aboutsummaryrefslogtreecommitdiff
path: root/tests/i
diff options
context:
space:
mode:
Diffstat (limited to 'tests/i')
-rw-r--r--tests/i/multifile-overloads/case.json7
-rw-r--r--tests/i/multifile-overloads/expected.txt2
-rw-r--r--tests/i/multifile-overloads/integer.cps3
-rw-r--r--tests/i/multifile-overloads/notes.md7
-rw-r--r--tests/i/multifile-overloads/program.cps4
-rw-r--r--tests/i/multifile-overloads/real.cps3
-rw-r--r--tests/i/overload-functions/case.json1
-rw-r--r--tests/i/overload-functions/expected.txt10
-rw-r--r--tests/i/overload-functions/notes.md9
-rw-r--r--tests/i/overload-functions/program.cps49
10 files changed, 95 insertions, 0 deletions
diff --git a/tests/i/multifile-overloads/case.json b/tests/i/multifile-overloads/case.json
new file mode 100644
index 0000000..dcbd7a4
--- /dev/null
+++ b/tests/i/multifile-overloads/case.json
@@ -0,0 +1,7 @@
+{
+ "sources": [
+ "program.cps",
+ "integer.cps",
+ "real.cps"
+ ]
+}
diff --git a/tests/i/multifile-overloads/expected.txt b/tests/i/multifile-overloads/expected.txt
new file mode 100644
index 0000000..6cf72e1
--- /dev/null
+++ b/tests/i/multifile-overloads/expected.txt
@@ -0,0 +1,2 @@
+6
+TRUE
diff --git a/tests/i/multifile-overloads/integer.cps b/tests/i/multifile-overloads/integer.cps
new file mode 100644
index 0000000..d2fd6d4
--- /dev/null
+++ b/tests/i/multifile-overloads/integer.cps
@@ -0,0 +1,3 @@
+OVERLOAD FUNCTION Area(x : INTEGER) RETURNS INTEGER
+RETURN x * 2
+ENDFUNCTION
diff --git a/tests/i/multifile-overloads/notes.md b/tests/i/multifile-overloads/notes.md
new file mode 100644
index 0000000..9a13837
--- /dev/null
+++ b/tests/i/multifile-overloads/notes.md
@@ -0,0 +1,7 @@
+# multifile-overloads
+
+Human review: pending. Expected output was independently traced by AI, not captured from cpsc.
+
+Basis: OVERLOAD is a project extension.
+
+Trace: Both libraries are visible: INTEGER 3 doubles to 6; REAL 2.0 compares greater than 1.0 and returns TRUE.
diff --git a/tests/i/multifile-overloads/program.cps b/tests/i/multifile-overloads/program.cps
new file mode 100644
index 0000000..35a9555
--- /dev/null
+++ b/tests/i/multifile-overloads/program.cps
@@ -0,0 +1,4 @@
+INCLUDE "integer.cps"
+INCLUDE "real.cps"
+OUTPUT Area(3)
+OUTPUT Area(2.0)
diff --git a/tests/i/multifile-overloads/real.cps b/tests/i/multifile-overloads/real.cps
new file mode 100644
index 0000000..3b5116a
--- /dev/null
+++ b/tests/i/multifile-overloads/real.cps
@@ -0,0 +1,3 @@
+OVERLOAD FUNCTION Area(x : REAL) RETURNS BOOLEAN
+RETURN x > 1.0
+ENDFUNCTION
diff --git a/tests/i/overload-functions/case.json b/tests/i/overload-functions/case.json
new file mode 100644
index 0000000..0967ef4
--- /dev/null
+++ b/tests/i/overload-functions/case.json
@@ -0,0 +1 @@
+{}
diff --git a/tests/i/overload-functions/expected.txt b/tests/i/overload-functions/expected.txt
new file mode 100644
index 0000000..65c760e
--- /dev/null
+++ b/tests/i/overload-functions/expected.txt
@@ -0,0 +1,10 @@
+3
+TRUE
+pair
+text
+7
+9
+TRUE
+3
+5
+TRUE
diff --git a/tests/i/overload-functions/notes.md b/tests/i/overload-functions/notes.md
new file mode 100644
index 0000000..dcfdde3
--- /dev/null
+++ b/tests/i/overload-functions/notes.md
@@ -0,0 +1,9 @@
+# overload-functions
+
+Human review: pending. Expected output was independently traced by AI, not captured from cpsc.
+
+Basis: OVERLOAD is a project extension.
+
+Trace: INTEGER adds one; positive REAL returns TRUE; two INTEGERs return pair; STRING prints text. Rank-one INTEGER, rank-two INTEGER and REAL arrays select distinct overloads and yield 7, 9 and TRUE. Nested Pick(1) returns INTEGER 2, so the outer call yields 3.
+
+Bump selects INTEGER and mutates 4 to 5 through BYREF. The ordinary Legacy function still converts INTEGER 1 to REAL and returns TRUE.
diff --git a/tests/i/overload-functions/program.cps b/tests/i/overload-functions/program.cps
new file mode 100644
index 0000000..e76637d
--- /dev/null
+++ b/tests/i/overload-functions/program.cps
@@ -0,0 +1,49 @@
+OVERLOAD FUNCTION Pick(x : INTEGER) RETURNS INTEGER
+RETURN x + 1
+ENDFUNCTION
+OVERLOAD FUNCTION Pick(x : REAL) RETURNS BOOLEAN
+RETURN x > 0
+ENDFUNCTION
+OVERLOAD FUNCTION Pick(x : INTEGER, y : INTEGER) RETURNS STRING
+RETURN "pair"
+ENDFUNCTION
+OVERLOAD PROCEDURE Pick(x : STRING)
+OUTPUT x
+ENDPROCEDURE
+OVERLOAD FUNCTION Pick(a : ARRAY OF INTEGER) RETURNS INTEGER
+RETURN a[1]
+ENDFUNCTION
+OVERLOAD FUNCTION Pick(a : ARRAY[1:2,1:2] OF INTEGER) RETURNS INTEGER
+RETURN a[2,2]
+ENDFUNCTION
+OVERLOAD FUNCTION Pick(a : ARRAY OF REAL) RETURNS BOOLEAN
+RETURN a[1] > 0
+ENDFUNCTION
+DECLARE a : ARRAY[1:2] OF INTEGER
+DECLARE b : ARRAY[1:2,1:2] OF INTEGER
+DECLARE c : ARRAY[1:2] OF REAL
+a[1] <- 7
+b[2,2] <- 9
+c[1] <- 1.0
+OUTPUT pIcK(2)
+OUTPUT Pick(2.0)
+OUTPUT Pick(1, 2)
+CALL Pick("text")
+OUTPUT Pick(a)
+OUTPUT Pick(b)
+OUTPUT Pick(c)
+OUTPUT Pick(Pick(1))
+OVERLOAD PROCEDURE Bump(BYREF x : INTEGER)
+x <- x + 1
+ENDPROCEDURE
+OVERLOAD PROCEDURE Bump(BYREF x : REAL)
+x <- x + 2.0
+ENDPROCEDURE
+FUNCTION Legacy(x : REAL) RETURNS BOOLEAN
+RETURN x > 0
+ENDFUNCTION
+DECLARE n : INTEGER
+n <- 4
+CALL Bump(n)
+OUTPUT n
+OUTPUT Legacy(1)