Skip to content

Commit

Permalink
test: Refactor lit code
Browse files Browse the repository at this point in the history
  • Loading branch information
volsa committed Nov 14, 2024
1 parent ab7c65a commit 9d028ee
Showing 1 changed file with 7 additions and 19 deletions.
26 changes: 7 additions & 19 deletions tests/lit/single/conversion/to_string.st
Original file line number Diff line number Diff line change
@@ -1,30 +1,18 @@
// RUN: (%COMPILE %s && %RUN) | %CHECK %s
FUNCTION main : DINT
VAR
myChar : CHAR;
myString : STRING[1];
END_VAR

// TODO: There's a bug, printf('%s$N', TO_CHAR(STRING#'foo')); returns a false positive
// TO_CHAR
myChar := TO_CHAR(WCHAR#"a");
printf('%c$N', myChar); // CHECK: a
myChar := TO_CHAR(STRING#'foo');
printf('%c$N', myChar); // CHECK: f
printf('%c$N', TO_CHAR(WCHAR#"a")); // CHECK: a
printf('%c$N', TO_CHAR(STRING#'foo')); // CHECK: f

// TO_WCHAR
printf('%c$N', TO_WCHAR(CHAR#'a')); // CHECK: a
printf('%c$N', TO_WCHAR(WSTRING#"foo")); // CHECK: f
printf('%c$N', TO_WCHAR(CHAR#'a')); // CHECK: a
printf('%c$N', TO_WCHAR(WSTRING#"foo")); // CHECK: f

// TO_STRING
myString := TO_STRING(CHAR#'a');
printf('%s$N', REF(myString)); // CHECK: a
printf('%s$N', REF(TO_STRING(WSTRING#"foo"))); // CHECK: foo
printf('%s$N', REF(TO_STRING(CHAR#'a'))); // CHECK: a
printf('%s$N', REF(TO_STRING(WSTRING#"foo"))); // CHECK: foo

// TO_WSTRING; yes, ~~fuck me~~ really we have to call TO_STRING on the result for printf to work...
// TO_WSTRING
printf('%s$N', REF(TO_STRING(TO_WSTRING(WCHAR#"a")))); // CHECK: a
printf('%s$N', REF(TO_STRING(TO_WSTRING(STRING#'foo')))); // CHECK: foo
END_FUNCTION

0 comments on commit 9d028ee

Please sign in to comment.