-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
stdlib: add
HashMap#includes
and HashSet#includes
, add tests
works on #88
- Loading branch information
Showing
5 changed files
with
131 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
fun main(): Unit { | ||
float64(); | ||
float32(); | ||
} | ||
|
||
fun float64(): Unit { | ||
let set = std::HashSet[Float64]::new(Float64::infinityPositive(), Float64::infinityNegative()); | ||
|
||
assert(set.size() == 2); | ||
assert(set.includes(Float64::infinityPositive())); | ||
assert(set.includes(Float64::infinityNegative())); | ||
} | ||
|
||
fun float32(): Unit { | ||
let set = std::HashSet[Float32]::new(Float32::infinityPositive(), Float32::infinityNegative()); | ||
|
||
assert(set.size() == 2); | ||
assert(set.includes(Float32::infinityPositive())); | ||
assert(set.includes(Float32::infinityNegative())); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
fun main(): Unit { | ||
float64(); | ||
float32(); | ||
} | ||
|
||
fun float64(): Unit { | ||
let set = std::HashSet[Float64]::new(Float64::notANumber()); | ||
|
||
assert(set.size() == 1i64); | ||
assert(set.includes(Float64::notANumber())); | ||
} | ||
|
||
fun float32(): Unit { | ||
let set = std::HashSet[Float32]::new(Float32::notANumber()); | ||
|
||
assert(set.size() == 1i64); | ||
assert(set.includes(Float32::notANumber())); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
fun main(): Unit { | ||
float64(); | ||
float32(); | ||
} | ||
|
||
fun float64(): Unit { | ||
let set = std::HashSet[Float64]::new(0.0); | ||
|
||
assert(set.size() == 1i64); | ||
assert(set.includes(0.0)); | ||
assert(set.includes(-0.0).not()); | ||
} | ||
|
||
fun float32(): Unit { | ||
let set = std::HashSet[Float32]::new(0.0f32); | ||
|
||
assert(set.size() == 1i64); | ||
assert(set.includes(0.0f32)); | ||
assert(set.includes(-0.0f32).not()); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
fun main(): Unit { | ||
let set = std::HashSet[Int32]::new(1i32, 10'000i32, 7i32); | ||
|
||
assert(set.size() == 3); | ||
assert(set.includes(1i32)); | ||
assert(set.includes(10'000i32)); | ||
assert(set.includes(7i32)); | ||
assert(set.includes(0i32).not()); | ||
} |