feat: implement floating-point number literal parsing and arithmetic operations
Add support for floating-point number literals in the parser by detecting decimal points with trailing digits in `readNumber()`, and switch the compiler's `number()` function from `strtol` to `strtod` for proper double conversion. Update the `num_abs` primitive to use `fabs()` instead of manual negation. Extend test coverage across arithmetic, comparison, equality, modulus, and string conversion tests with floating-point cases, and add a new test for decimal point at end-of-file error detection.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
io.write(123 == 123) // expect: true
|
||||
io.write(123 == 124) // expect: false
|
||||
io.write(-3 == 3) // expect: false
|
||||
io.write(0 == -0) // expect: true
|
||||
|
||||
// Not equal to other types.
|
||||
io.write(123 == "123") // expect: false
|
||||
@@ -10,10 +11,9 @@ io.write(0 == false) // expect: false
|
||||
io.write(123 != 123) // expect: false
|
||||
io.write(123 != 124) // expect: true
|
||||
io.write(-3 != 3) // expect: true
|
||||
io.write(0 != -0) // expect: false
|
||||
|
||||
// Not equal to other types.
|
||||
io.write(123 != "123") // expect: true
|
||||
io.write(1 != true) // expect: true
|
||||
io.write(0 != false) // expect: true
|
||||
|
||||
// TODO(bob): Should 0 == -0?
|
||||
Reference in New Issue
Block a user