aboutsummaryrefslogtreecommitdiff
path: root/tests/i/preprocessor
diff options
context:
space:
mode:
author_ov4 <ov4@ov4.org>2026-10-27 13:55:36 +0000
committer_ov4 <ov4@ov4.org>2026-10-27 13:55:36 +0000
commita91bd145008432fb8c5d91d94ab6f50473a277f5 (patch)
tree87af3ebcd2888e129bad9863574567e1c97bb18b /tests/i/preprocessor
parent24f410430b33aaf1f288b83ea37e18fa959e9d3e (diff)
feat(preprocessor): add file-local conditional switches
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'tests/i/preprocessor')
-rw-r--r--tests/i/preprocessor/case.json6
-rw-r--r--tests/i/preprocessor/expected.txt8
-rw-r--r--tests/i/preprocessor/notes.md5
-rw-r--r--tests/i/preprocessor/peer.cps9
-rw-r--r--tests/i/preprocessor/program.cps44
5 files changed, 72 insertions, 0 deletions
diff --git a/tests/i/preprocessor/case.json b/tests/i/preprocessor/case.json
new file mode 100644
index 0000000..c66d109
--- /dev/null
+++ b/tests/i/preprocessor/case.json
@@ -0,0 +1,6 @@
+{
+ "sources": [
+ "program.cps",
+ "peer.cps"
+ ]
+}
diff --git a/tests/i/preprocessor/expected.txt b/tests/i/preprocessor/expected.txt
new file mode 100644
index 0000000..d537856
--- /dev/null
+++ b/tests/i/preprocessor/expected.txt
@@ -0,0 +1,8 @@
+1
+2
+3
+4
+5
+6
+7
+PP_DEFINE Quoted
diff --git a/tests/i/preprocessor/notes.md b/tests/i/preprocessor/notes.md
new file mode 100644
index 0000000..2afe007
--- /dev/null
+++ b/tests/i/preprocessor/notes.md
@@ -0,0 +1,5 @@
+# Trace notes
+
+Review status: pending human review.
+
+The main file enables MainFlag, independently checks lowercase mainflag, and skips a disabled nested region containing invalid source and switch changes. Hidden remains undefined and MainFlag remains defined until explicitly removed. A switch named Flag does not replace the ordinary variable. Neither input sees the other's switches. Enabled branches print 1 through 7, followed by a literal containing a directive name. These are compiler extensions.
diff --git a/tests/i/preprocessor/peer.cps b/tests/i/preprocessor/peer.cps
new file mode 100644
index 0000000..bb745c3
--- /dev/null
+++ b/tests/i/preprocessor/peer.cps
@@ -0,0 +1,9 @@
+PP_DEFINE PeerFlag
+PROCEDURE Peer()
+PP_IFDEF MainFlag
+OUTPUT MissingMainFlag
+PP_ENDIF
+PP_IFDEF PeerFlag
+OUTPUT 7
+PP_ENDIF
+ENDPROCEDURE
diff --git a/tests/i/preprocessor/program.cps b/tests/i/preprocessor/program.cps
new file mode 100644
index 0000000..fe0b9ce
--- /dev/null
+++ b/tests/i/preprocessor/program.cps
@@ -0,0 +1,44 @@
+PP_DEFINE MainFlag // File-local and case-sensitive.
+PP_DEFINE MainFlag
+INCLUDE "peer.cps"
+PP_IFDEF MainFlag
+OUTPUT 1
+PP_ENDIF
+PP_IFNDEF mainflag
+OUTPUT 2
+PP_ENDIF
+PP_IFDEF PeerFlag
+OUTPUT MissingPeerFlag
+PP_ENDIF
+PP_IFDEF Absent
+"unterminated literal
+PP_DEFINE Hidden
+PP_UNDEF MainFlag
+PP_IFNDEF Other
+#INVALID
+PP_DEFINE
+PP_ENDIF
+PP_ENDIF
+PP_IFNDEF Hidden
+OUTPUT 3
+PP_ENDIF
+PP_IFDEF MainFlag
+OUTPUT 4
+PP_ENDIF
+PP_UNDEF MainFlag
+PP_UNDEF MainFlag
+PP_IFDEF MainFlag
+OUTPUT MissingMainFlag
+PP_ENDIF
+PP_IFNDEF MainFlag
+ PP_IFNDEF Hidden // Nested enabled conditions.
+OUTPUT 5
+ PP_ENDIF
+PP_ENDIF
+DECLARE Flag : INTEGER
+PP_DEFINE Flag
+Flag <- 6
+OUTPUT Flag
+CALL Peer()
+// PP_IFDEF CommentedOut
+OUTPUT "PP_DEFINE Quoted"