Files
wren/test/number/sqrt.wren
T
Evan Shaw 75d28c083c Don't treat negative numbers as literals
Fixes #93.

Previously, "1 -1" was lexed as two number tokens: a positive literal and
a negative literal. This caused problems when it came to parsing.

Now the '-' and the second number are separate tokens.

Note this is a breaking change, since `-16.sqrt` is now parsed as `-(16.sqrt)`,
as opposed to `(-16).sqrt`.

There is a small bit of overhead to doing it this way, but it might be possible
to optimize that out in the compiler at some point in the future.
2015-01-09 20:17:40 +13:00

11 lines
316 B
Plaintext

IO.print(4.sqrt) // expect: 2
IO.print(1000000.sqrt) // expect: 1000
IO.print(1.sqrt) // expect: 1
IO.print((-0).sqrt) // expect: -0
IO.print(0.sqrt) // expect: 0
IO.print(2.sqrt) // expect: 1.4142135623731
IO.print((-4).sqrt.isNan) // expect: true
// TODO: Tests for sin and cos.