Make Range a native object type.

Still need to implement better semantics, but this is an 
important first step. It's much faster now too, which is good.
This commit is contained in:
Bob Nystrom
2014-01-20 08:45:15 -08:00
parent d40d04f0c5
commit 97bf314f4b
15 changed files with 291 additions and 88 deletions
+26
View File
@@ -0,0 +1,26 @@
// Ordered range.
IO.print((2..5).min) // expect: 2
IO.print((3..3).min) // expect: 3
IO.print((0..3).min) // expect: 0
IO.print((-5..3).min) // expect: -5
IO.print((-5..-2).min) // expect: -5
// Backwards range.
IO.print((5..2).min) // expect: 2
IO.print((3..0).min) // expect: 0
IO.print((3..-5).min) // expect: -5
IO.print((-2..-5).min) // expect: -5
// Exclusive ordered range.
IO.print((2...5).min) // expect: 2
IO.print((3...3).min) // expect: 2
IO.print((0...3).min) // expect: 0
IO.print((-5...3).min) // expect: -5
IO.print((-5...-2).min) // expect: -5
// Exclusive backwards range.
// TODO: Is this what we want? "..." always means "subtract 1"?
IO.print((5...2).min) // expect: 1
IO.print((3...0).min) // expect: -1
IO.print((3...-5).min) // expect: -6
IO.print((-2...-5).min) // expect: -6