feat: add overloaded IO.print methods accepting 2-16 arguments and printList_ helper
Add 15 static overloads of IO.print in builtin/io.wren and src/wren_io.c, each delegating to a new private printList_ method that iterates over a list of objects. Update all benchmark and test files to use the new multi-argument syntax, removing explicit .toString calls and string concatenation. Add a comprehensive test/io/print.wren verifying single-argument return value, multi-argument null return, and concatenation of up to 16 arguments.
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
// With one argument, returns the argument.
|
||||
IO.print(IO.print(1) == 1) // expect: 1
|
||||
// expect: true
|
||||
|
||||
// With more than one argument, returns null.
|
||||
IO.print(IO.print(1, 2) == null) // expect: 12
|
||||
// expect: true
|
||||
|
||||
// Allows multiple arguments and concatenates them.
|
||||
IO.print(1) // expect: 1
|
||||
IO.print(1, 2) // expect: 12
|
||||
IO.print(1, 2, 3) // expect: 123
|
||||
IO.print(1, 2, 3, 4) // expect: 1234
|
||||
IO.print(1, 2, 3, 4, 5) // expect: 12345
|
||||
IO.print(1, 2, 3, 4, 5, 6) // expect: 123456
|
||||
IO.print(1, 2, 3, 4, 5, 6, 7) // expect: 1234567
|
||||
IO.print(1, 2, 3, 4, 5, 6, 7, 8) // expect: 12345678
|
||||
IO.print(1, 2, 3, 4, 5, 6, 7, 8, 9) // expect: 123456789
|
||||
IO.print(1, 2, 3, 4, 5, 6, 7, 8, 9, 10) // expect: 12345678910
|
||||
IO.print(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11) // expect: 1234567891011
|
||||
IO.print(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12) // expect: 123456789101112
|
||||
IO.print(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13) // expect: 12345678910111213
|
||||
IO.print(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14) // expect: 1234567891011121314
|
||||
IO.print(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15) // expect: 123456789101112131415
|
||||
IO.print(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16) // expect: 12345678910111213141516
|
||||
Reference in New Issue
Block a user