Commit Graph

2 Commits

Author SHA1 Message Date
Gavin Schulz
8278701635 test: add edge-case tests for Num.fromString with whitespace, prefix, and non-string args
Add test cases for Num.fromString covering leading/trailing whitespace (" 12 "),
numeric prefix with trailing non-numeric characters ("1.2prefix"), empty string,
non-numeric prefix ("prefix1.2"), and a runtime error test for non-string argument
(Num.fromString(1)).
2015-02-25 07:44:03 +00:00
Gavin Schulz
87cc5fdbae feat: add Num.fromString static method to parse decimal string literals
Implements a new `fromString` static method on the `Num` class that attempts to parse a string as a decimal number literal using `strtod`. Returns the parsed `Num` value on success, or `null` if the string does not represent a valid number. Includes runtime validation that the argument is a string, and adds test coverage for positive, negative, zero, and decimal inputs as well as non-numeric strings.
2015-02-23 04:06:17 +00:00