Skip to content

Commit 05b6471

Browse files
committed
file IO: add sprintf tests
1 parent 22118f3 commit 05b6471

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

src/main/java/org/perlonjava/runtime/GlobalContext.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,10 @@ public static RuntimeScalar getGlobalVariable(String key) {
141141
return var;
142142
}
143143

144+
public static RuntimeScalar setGlobalVariable(String key, String value) {
145+
return getGlobalVariable(key).set(value);
146+
}
147+
144148
public static boolean existsGlobalVariable(String key) {
145149
return globalVariables.containsKey(key);
146150
}

src/test/resources/operations.pl

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -154,12 +154,11 @@
154154
my $negative_width = sprintf("|%-10s|", "test");
155155
print "not " if $negative_width ne "|test |"; say "ok # sprintf('|%-10s|', 'test') |$negative_width|";
156156

157-
## XXX TODO
158-
## # Test invalid format string
159-
## my $invalid_format;
160-
## eval { $invalid_format = sprintf("%z", "data") };
161-
## print "not " if $@; # Expecting an error
162-
## print "ok # sprintf with invalid format string causes an error\n";
157+
# Test invalid format string
158+
my $invalid_format;
159+
eval { $invalid_format = sprintf("%z", "data") };
160+
print "not " if $@; # Expecting an error
161+
print "ok # sprintf with invalid format string causes an error\n";
163162

164163
###################
165164
# Logical Operators

0 commit comments

Comments
 (0)