-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move tests from stdlib files to examples/stdlib tests
- Loading branch information
1 parent
8a50435
commit 88c4f5e
Showing
9 changed files
with
99 additions
and
84 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
HeapTests | ||
✓ simple heap sort on integers | ||
|
||
1 pass | ||
0 fail | ||
1 tests total |
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,27 @@ | ||
import heap | ||
import test | ||
|
||
def main() = { | ||
suite("HeapTests", false) { | ||
test("simple heap sort on integers") { | ||
with on[OutOfBounds].default { assertTrue(false); <> }; | ||
val h = heap[Int](box { (x: Int, y: Int) => | ||
if (x < y) { | ||
Less() | ||
} else Greater() // hacky, should sometimes be Equal() | ||
}) | ||
h.insert(12) | ||
h.insert(10) | ||
h.insert(7) | ||
h.insert(11) | ||
h.insert(14) | ||
assert(h.deleteMin(), 7) | ||
assert(h.deleteMin(), 10) | ||
assert(h.deleteMin(), 11) | ||
assert(h.deleteMin(), 12) | ||
assert(h.deleteMin(), 14) | ||
assert(h.size, 0) | ||
} | ||
}; | ||
() | ||
} |
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,6 @@ | ||
ResizableArrayTests | ||
✓ usage as stack | ||
|
||
1 pass | ||
0 fail | ||
1 tests total |
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,33 @@ | ||
import resizable_array | ||
import test | ||
|
||
def main() = { | ||
suite("ResizableArrayTests", false) { | ||
test("usage as stack") { | ||
with on[OutOfBounds].default { assertTrue(false, "out of bounds") } | ||
val a = resizableArray() | ||
a.add(1) | ||
a.add(1) | ||
a.add(2) | ||
a.add(3) | ||
a.add(13) | ||
a.add(21) | ||
a.add(34) | ||
a.add(55) | ||
assert(a.popRight(), 55) | ||
assert(a.popRight(), 34) | ||
assert(a.popRight(), 21) | ||
assert(a.popRight(), 13) | ||
a.add(5) | ||
a.add(8) | ||
assert(a.popRight(), 8) | ||
assert(a.popRight(), 5) | ||
assert(a.popRight(), 3) | ||
assert(a.popRight(), 2) | ||
assert(a.popRight(), 1) | ||
assert(a.popRight(), 1) | ||
} | ||
// TODO | ||
}; | ||
() | ||
} |
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,6 @@ | ||
UnionFindTests | ||
✓ three elements | ||
|
||
1 pass | ||
0 fail | ||
1 tests total |
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,21 @@ | ||
import union_find | ||
import test | ||
|
||
def main() = { | ||
suite("UnionFindTests", false) { | ||
test("three elements") { | ||
with on[MissingValue].default { assertTrue(false, "MissingValue exception") } | ||
val u = unionFind() | ||
val a = u.makeSet() | ||
val b = u.makeSet() | ||
val c = u.makeSet() | ||
assert(u.find(a), a) | ||
assert(u.find(b), b) | ||
assert(u.find(c), c) | ||
u.union(a,b) | ||
assert(u.find(a), u.find(b)) | ||
assert(u.find(c), c) | ||
} | ||
}; | ||
() | ||
} |
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
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