Skip to content

Commit

Permalink
[ test ] Add bigger tests for sorted trees
Browse files Browse the repository at this point in the history
  • Loading branch information
buzden committed Nov 11, 2024
1 parent 7283586 commit 4bf9af5
Show file tree
Hide file tree
Showing 16 changed files with 584 additions and 0 deletions.
20 changes: 20 additions & 0 deletions examples/sorted-tree-indexed/tests/gens/sorted-big/Main.idr
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import Data.SortedBinTree.Gen
import Data.Fuel
import Data.List
import Data.List.Lazy
import Data.Primitives.Interpolation

import System.Random.Pure.StdGen

%default total

main : IO ()
main = do
let vals = unGenTryN 10 someStdGen $ genSortedBinTree1 $ limit 10
Lazy.for_ vals $ \(mi ** ma ** tree) => do
putStrLn "--------------"
let list = toList tree
putStrLn "min: \{mi}, max: \{ma}, length: \{length list}"
putStrLn "tree:\n\{tree}"
putStrLn "as list: \{show list}"
putStrLn "sorted: \{show $ sorted list}"
324 changes: 324 additions & 0 deletions examples/sorted-tree-indexed/tests/gens/sorted-big/expected
Original file line number Diff line number Diff line change
@@ -0,0 +1,324 @@
--------------
min: 4, max: 12, length: 5
tree:
.
|
|- .
| |
| |- .
| | |
| | |- .
| | | |
| | | |- 4
| | | |
| | | |- 7
| | |
| | |- 8
| |
| |- 9
|
|- 12
as list: [4, 7, 8, 9, 12]
sorted: True
--------------
min: 4, max: 11, length: 6
tree:
.
|
|- .
| |
| |- .
| | |
| | |- .
| | | |
| | | |- 4
| | | |
| | | |- .
| | | |
| | | |- 6
| | | |
| | | |- 7
| | |
| | |- 8
| |
| |- 9
|
|- 11
as list: [4, 6, 7, 8, 9, 11]
sorted: True
--------------
min: 5, max: 15, length: 6
tree:
.
|
|- .
| |
| |- .
| | |
| | |- .
| | | |
| | | |- .
| | | | |
| | | | |- 5
| | | | |
| | | | |- 6
| | | |
| | | |- 7
| | |
| | |- 8
| |
| |- 9
|
|- 15
as list: [5, 6, 7, 8, 9, 15]
sorted: True
--------------
min: 3, max: 19, length: 4
tree:
.
|
|- 3
|
|- .
|
|- .
| |
| |- 8
| |
| |- 9
|
|- 19
as list: [3, 8, 9, 19]
sorted: True
--------------
min: 3, max: 17, length: 8
tree:
.
|
|- .
| |
| |- .
| | |
| | |- .
| | | |
| | | |- .
| | | | |
| | | | |- .
| | | | | |
| | | | | |- .
| | | | | | |
| | | | | | |- 3
| | | | | | |
| | | | | | |- 4
| | | | | |
| | | | | |- 5
| | | | |
| | | | |- 6
| | | |
| | | |- 7
| | |
| | |- 8
| |
| |- 9
|
|- 17
as list: [3, 4, 5, 6, 7, 8, 9, 17]
sorted: True
--------------
min: 0, max: 14, length: 9
tree:
.
|
|- .
| |
| |- .
| | |
| | |- .
| | | |
| | | |- .
| | | | |
| | | | |- .
| | | | | |
| | | | | |- .
| | | | | | |
| | | | | | |- .
| | | | | | | |
| | | | | | | |- 0
| | | | | | | |
| | | | | | | |- 3
| | | | | | |
| | | | | | |- 4
| | | | | |
| | | | | |- 5
| | | | |
| | | | |- 6
| | | |
| | | |- 7
| | |
| | |- 8
| |
| |- 9
|
|- 14
as list: [0, 3, 4, 5, 6, 7, 8, 9, 14]
sorted: True
--------------
min: 0, max: 12, length: 11
tree:
.
|
|- .
| |
| |- .
| | |
| | |- .
| | | |
| | | |- .
| | | | |
| | | | |- .
| | | | | |
| | | | | |- .
| | | | | | |
| | | | | | |- .
| | | | | | | |
| | | | | | | |- .
| | | | | | | | |
| | | | | | | | |- .
| | | | | | | | | |
| | | | | | | | | |- 0
| | | | | | | | | |
| | | | | | | | | |- 1
| | | | | | | | |
| | | | | | | | |- 2
| | | | | | | |
| | | | | | | |- 3
| | | | | | |
| | | | | | |- 4
| | | | | |
| | | | | |- 5
| | | | |
| | | | |- 6
| | | |
| | | |- 7
| | |
| | |- 8
| |
| |- 9
|
|- 12
as list: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 12]
sorted: True
--------------
min: 0, max: 12, length: 11
tree:
.
|
|- .
| |
| |- .
| | |
| | |- .
| | | |
| | | |- .
| | | | |
| | | | |- .
| | | | | |
| | | | | |- .
| | | | | | |
| | | | | | |- .
| | | | | | | |
| | | | | | | |- .
| | | | | | | | |
| | | | | | | | |- .
| | | | | | | | | |
| | | | | | | | | |- 0
| | | | | | | | | |
| | | | | | | | | |- 1
| | | | | | | | |
| | | | | | | | |- 2
| | | | | | | |
| | | | | | | |- 3
| | | | | | |
| | | | | | |- 4
| | | | | |
| | | | | |- 5
| | | | |
| | | | |- 6
| | | |
| | | |- 7
| | |
| | |- 8
| |
| |- 9
|
|- 12
as list: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 12]
sorted: True
--------------
min: 1, max: 17, length: 10
tree:
.
|
|- .
| |
| |- .
| | |
| | |- .
| | | |
| | | |- .
| | | | |
| | | | |- .
| | | | | |
| | | | | |- .
| | | | | | |
| | | | | | |- .
| | | | | | | |
| | | | | | | |- .
| | | | | | | | |
| | | | | | | | |- 1
| | | | | | | | |
| | | | | | | | |- 2
| | | | | | | |
| | | | | | | |- 3
| | | | | | |
| | | | | | |- 4
| | | | | |
| | | | | |- 5
| | | | |
| | | | |- 6
| | | |
| | | |- 7
| | |
| | |- 8
| |
| |- 9
|
|- 17
as list: [1, 2, 3, 4, 5, 6, 7, 8, 9, 17]
sorted: True
--------------
min: 5, max: 18, length: 6
tree:
.
|
|- .
| |
| |- .
| | |
| | |- .
| | | |
| | | |- .
| | | | |
| | | | |- 5
| | | | |
| | | | |- 6
| | | |
| | | |- 7
| | |
| | |- 8
| |
| |- 9
|
|- 18
as list: [5, 6, 7, 8, 9, 18]
sorted: True
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package a-test

depends = sorted-tree-indexed

executable = a-test
main = Main
6 changes: 6 additions & 0 deletions examples/sorted-tree-naive/tests/gens/sorted-big/run
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
rm -rf build

flock "$1" pack -q install-deps test.ipkg && \
pack run test.ipkg

rm -rf build
20 changes: 20 additions & 0 deletions examples/sorted-tree-naive/tests/gens/sorted-small/Main.idr
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import Data.SortedBinTree.Gen
import Data.Fuel
import Data.List
import Data.List.Lazy
import Data.Primitives.Interpolation

import System.Random.Pure.StdGen

%default total

main : IO ()
main = do
let vals = unGenTryN 10 someStdGen $ genSortedBinTree $ limit 5
Lazy.for_ vals $ \tree => do
putStrLn "--------------"
let list = toList tree
putStrLn "length: \{length list}"
putStrLn "tree:\n\{tree}"
putStrLn "as list: \{show list}"
putStrLn "sorted: \{show $ sorted list}"
Loading

0 comments on commit 4bf9af5

Please sign in to comment.