Files
wren/test/core/number/from_string.wren

15 lines
724 B
Plaintext
Raw Normal View History

System.print(Num.fromString("123") == 123) // expect: true
System.print(Num.fromString("-123") == -123) // expect: true
System.print(Num.fromString("-0") == -0) // expect: true
System.print(Num.fromString("12.34") == 12.34) // expect: true
System.print(Num.fromString("-0.0001") == -0.0001) // expect: true
System.print(Num.fromString(" 12 ") == 12) // expect: true
2015-02-24 23:44:03 -08:00
// Test some non-number literals and ensure they return null.
System.print(Num.fromString("test1") == null) // expect: true
System.print(Num.fromString("") == null) // expect: true
System.print(Num.fromString("prefix1.2") == null) // expect: true
System.print(Num.fromString("1.2suffix") == null) // expect: true
2015-02-24 23:44:03 -08:00
// TODO: Parse hex and scientific numbers.