From 96fd8bab8630f2abcc74cfc69fdbccc530579b9c Mon Sep 17 00:00:00 2001 From: _ov4 Date: Wed, 28 Oct 2026 13:38:00 +0000 Subject: feat(library): add contextual conversion return overloads Co-Authored-By: Claude Opus 5.5 --- tests/i/contextual-conversions/program.cps | 36 ++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 tests/i/contextual-conversions/program.cps (limited to 'tests/i/contextual-conversions/program.cps') diff --git a/tests/i/contextual-conversions/program.cps b/tests/i/contextual-conversions/program.cps new file mode 100644 index 0000000..a90a815 --- /dev/null +++ b/tests/i/contextual-conversions/program.cps @@ -0,0 +1,36 @@ +DECLARE N : INTEGER +DECLARE Ch : CHAR +DECLARE Text : STRING +OUTPUT STR_TO_NUM("23.45") +OUTPUT STR_TO_NUM('7') +N <- STR_TO_NUM("23.45") +OUTPUT N +N <- STR_TO_NUM("-23.45") +OUTPUT N +N <- STR_TO_NUM('7') +OUTPUT N +OUTPUT NUM_TO_STR(7), ":", NUM_TO_STR(7.0) +Ch <- NUM_TO_STR(7) +OUTPUT Ch +Text <- NUM_TO_STR(12) +OUTPUT Text +TRY + Ch <- NUM_TO_STR(12) +CATCH + OUTPUT "length caught" +ENDTRY +TRY + Ch <- NUM_TO_STR(7.0) +CATCH + OUTPUT "real length caught" +ENDTRY +TRY + N <- STR_TO_NUM("bad") +CATCH + OUTPUT "invalid caught" +ENDTRY +TRY + N <- STR_TO_NUM("1e30") +CATCH + OUTPUT "range caught" +ENDTRY -- cgit v1.3.1-4-g156e