From f4a39bc9438d775455c4aba525ab9ace7e181d69 Mon Sep 17 00:00:00 2001 From: Gavin Schulz Date: Tue, 24 Feb 2015 23:44:03 -0800 Subject: [PATCH] Code review changes. --- test/number/from_string.wren | 7 ++++++- test/number/from_string_not_string.wren | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 test/number/from_string_not_string.wren diff --git a/test/number/from_string.wren b/test/number/from_string.wren index b51bfe0e..546db0f2 100644 --- a/test/number/from_string.wren +++ b/test/number/from_string.wren @@ -3,6 +3,11 @@ IO.print(Num.fromString("-123") == -123) // expect: true IO.print(Num.fromString("-0") == -0) // expect: true IO.print(Num.fromString("12.34") == 12.34) // expect: true IO.print(Num.fromString("-0.0001") == -0.0001) // expect: true +IO.print(Num.fromString(" 12 ") == 12) // expect: true +IO.print(Num.fromString("1.2prefix") == 1.2) // expect: true -// Test a non-number literal and ensure it returns null. +// Test some non-number literals and ensure they return null. IO.print(Num.fromString("test1") == null) // expect: true +IO.print(Num.fromString("") == null) // expect: true +IO.print(Num.fromString("prefix1.2") == null) // expect: true + diff --git a/test/number/from_string_not_string.wren b/test/number/from_string_not_string.wren new file mode 100644 index 00000000..54f387bd --- /dev/null +++ b/test/number/from_string_not_string.wren @@ -0,0 +1 @@ +Num.fromString(1) // expect runtime error: Argument must be a string. \ No newline at end of file