USING: s tools.testest locals math.functions kernel math math.ranges sequences random formatting ; IN: s.tests : randint ( m n -- r ) over - random + ; : refsol-s-42248 ( m n -- res ) swap [0,b) dup rot 1 [ [ + ] curry map product ] bi-curry@ bi* /i ; :: run-tests ( -- ) "Sample Tests" describe#{ "should work for small inputs" it#{ <{ 1 1 s -> 1 }> <{ 0 53 s -> 1 }> <{ 1 49 s -> 49 }> <{ 1 101 s -> 101 }> <{ 2 5 s -> 15 }> <{ 2 99 s -> 4950 }> <{ 3 7 s -> 84 }> <{ 3 32 s -> 5984 }> <{ 4 8 s -> 330 }> <{ 5 17 s -> 20349 }> <{ 10 4 s -> 286 }> }# "should work for edge cases" it#{ <{ 0 1 s -> 1 }> <{ 1 1 s -> 1 }> <{ 0 10 100 ^ s -> 1 }> <{ 1 10 100 ^ s -> 10 100 ^ }> }# }# "Random Tests" describe#{ "Small Random Tests" describe#{ 25 [ 0 10 randint :> m 1 100 randint :> n { m n } "Testing m=%d, n=%d" vsprintf it#{ <{ m n s -> m n refsol-s-42248 }> }# ] times }# "Big Random Tests" it#{ 125 [ 0 100 randint :> m 1 10 100 ^ randint :> n <{ m n s -> m n refsol-s-42248 }> ] times }# }# ; MAIN: run-tests