aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
author_ov4 <ov4@ov4.org>2026-10-18 08:09:06 +0000
committer_ov4 <ov4@ov4.org>2026-10-18 08:09:06 +0000
commit30fced09675acfd2b9ab6db6be8359a70d3f0402 (patch)
tree88dc4587cb71d9dc9bdd9a57c4e2de8a98d7f06e /tests
parent345e3d419eafb0e234aecb4a33f37efe2afbbf53 (diff)
feat(operators): allow member assignment operator overloads
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/i/operator-assign/case.json1
-rw-r--r--tests/i/operator-assign/expected.txt7
-rw-r--r--tests/i/operator-assign/program.cps39
-rw-r--r--tests/iii/operator-assign-global/case.json1
-rw-r--r--tests/iii/operator-assign-global/program.cps3
5 files changed, 51 insertions, 0 deletions
diff --git a/tests/i/operator-assign/case.json b/tests/i/operator-assign/case.json
new file mode 100644
index 0000000..0967ef4
--- /dev/null
+++ b/tests/i/operator-assign/case.json
@@ -0,0 +1 @@
+{}
diff --git a/tests/i/operator-assign/expected.txt b/tests/i/operator-assign/expected.txt
new file mode 100644
index 0000000..aaf45ba
--- /dev/null
+++ b/tests/i/operator-assign/expected.txt
@@ -0,0 +1,7 @@
+copy:3
+copy:3
+copy:7
+copy:7
+copy:5
+copy:7
+7:7:7:5
diff --git a/tests/i/operator-assign/program.cps b/tests/i/operator-assign/program.cps
new file mode 100644
index 0000000..d534806
--- /dev/null
+++ b/tests/i/operator-assign/program.cps
@@ -0,0 +1,39 @@
+CLASS Value
+ N : INTEGER
+ OVERLOAD PROCEDURE NEW()
+ ENDPROCEDURE
+ OVERLOAD PROCEDURE NEW(BYREF Other : Value)
+ N <- Other.N
+ ENDPROCEDURE
+ OVERLOAD PROCEDURE OPERATOR<-(BYREF Other : Value)
+ OUTPUT "copy:", Other.N
+ N <- Other.N
+ ENDPROCEDURE
+ OVERLOAD PROCEDURE OPERATOR<-(Text : C_STRING)
+ N <- LENGTH((STRING)Text)
+ ENDPROCEDURE
+ENDCLASS
+FUNCTION Make() RETURNS Value
+ DECLARE X : Value
+ X.N <- 7
+ RETURN X
+ENDFUNCTION
+TYPE ValuePtr = ^Value
+TYPE Box
+ DECLARE Item : Value
+ENDTYPE
+DECLARE A : Value
+DECLARE B : Value
+A.N <- 3
+B <- A
+B <- B
+B <- Make()
+A <- (C_STRING)"hello"
+DECLARE R : Box
+R.Item <- B
+DECLARE Items : ARRAY[1:1] OF Value
+Items[1] <- A
+DECLARE P : ValuePtr
+P <- ^A
+P^ <- B
+OUTPUT A.N, ":", B.N, ":", R.Item.N, ":", Items[1].N
diff --git a/tests/iii/operator-assign-global/case.json b/tests/iii/operator-assign-global/case.json
new file mode 100644
index 0000000..7a2e21d
--- /dev/null
+++ b/tests/iii/operator-assign-global/case.json
@@ -0,0 +1 @@
+{"errors":[{"reason":"Assignment operator must be","line":1}]}
diff --git a/tests/iii/operator-assign-global/program.cps b/tests/iii/operator-assign-global/program.cps
new file mode 100644
index 0000000..6f6454e
--- /dev/null
+++ b/tests/iii/operator-assign-global/program.cps
@@ -0,0 +1,3 @@
+OVERLOAD PROCEDURE OPERATOR<-(X : INTEGER)
+ENDPROCEDURE
+OUTPUT 0