Merged
Show file tree
Hide file tree
Changes from 1 commit
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Failed to load files.
Previous commit
Next commit
assert: more tests
  • Loading branch information
@aspeddro
aspeddro committedApr 14, 2023
commit 2e9449c5cb9beaf5392add99e8ea233543ec5e2b
Binary file not shown.
Original file line numberDiff line numberDiff line change
Expand Up@@ -10,15 +10,15 @@ let ff = x =>
| "a" => #a
| "b" => #b
| "c" => #c
| _ => assert false
| _ => assert(false)
}

let test = x =>
switch switch x {
| "a" => #a
| "b" => #b
| "c" => #c
| _ => assert false
| _ => assert(false)
} {
| #a => "a"
| #b => "b"
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -48,15 +48,15 @@ let () = {
__LOC__,
{
let v = [1, 2]
assert A.set(v, 0, 0)
assert(A.set(v, 0, 0))
A.getExn(v, 0) == 0
},
)
b(
__LOC__,
{
let v = [1, 2]
assert A.set(v, 1, 0)
assert(A.set(v, 1, 0))
A.getExn(v, 1) == 0
},
)
Expand DownExpand Up@@ -150,7 +150,7 @@ let addone = (. x) => x + 1

let makeMatrixExn = (sx, sy, init) => {
/* let open A in */
assert (sx >= 0 && sy >= 0)
assert(sx >= 0 && sy >= 0)
let res = A.makeUninitializedUnsafe(sx)
for x in 0 to sx - 1 {
let initY = A.makeUninitializedUnsafe(sy)
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -34,7 +34,7 @@ let bench = () => {
N.set(empty, i, i)
}
for i in 0 to count {
assert mem(empty, i)
assert(mem(empty, i))
}
N.logStats(empty)
}
Expand All@@ -58,7 +58,7 @@ let bench2 = (type t, m: Belt.Id.hashable<string, t>) => {
M.set(empty, string_of_int(i), i)
}
for i in 0 to count {
assert M.has(empty, string_of_int(i))
assert(M.has(empty, string_of_int(i)))
}
for i in 0 to count {
M.remove(empty, string_of_int(i))
Expand All@@ -78,7 +78,7 @@ let bench3 = (type t, m: Belt.Id.comparable<string, t>) => {
table := Md0.set(~cmp, table.contents, string_of_int(i), i)
}
for i in 0 to count {
assert Md0.has(~cmp, table.contents, string_of_int(i))
assert(Md0.has(~cmp, table.contents, string_of_int(i)))
}
for i in 0 to count {
table := Md0.remove(~cmp, table.contents, string_of_int(i))
Expand All@@ -95,12 +95,12 @@ let bench4 = () => {
H.set(table, string_of_int(i), i)
}
for i in 0 to count {
assert H.has(table, string_of_int(i))
assert(H.has(table, string_of_int(i)))
}
for i in 0 to count {
H.remove(table, string_of_int(i))
}
assert H.isEmpty(table)
assert(H.isEmpty(table))
}

module H0 = Belt.HashMap
Expand All@@ -116,15 +116,15 @@ let bench5 = () => {
)
%time(
for i in 0 to count {
assert H0.has(table, i)
assert(H0.has(table, i))
}
)
%time(
for i in 0 to count {
H0.remove(table, i)
}
)
assert H0.isEmpty(table)
assert(H0.isEmpty(table))
}

module HI = Belt.HashMap.Int
Expand All@@ -135,7 +135,7 @@ let bench6 = () => {
HI.set(table, i, i)
}
for i in 0 to count {
assert HI.has(table, i)
assert(HI.has(table, i))
}
for i in 0 to count {
HI.remove(table, i)
Expand All@@ -157,7 +157,7 @@ let bench7 = () => {

/* [%time */
for i in 0 to count {
assert S.has(table, i)
assert(S.has(table, i))
}
/* ] */

Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -35,15 +35,15 @@ let () = {
assert (Q.toArray(q) == [4] && Q.size(q) == 1)
assert (Q.popExn(q) == 4)
assert (Q.toArray(q) == [] && Q.size(q) == 0)
assert does_raise(Q.popExn, q)
assert(does_raise(Q.popExn, q))
}

let () = {
let q = Q.make()
assert (Q.popExn(\"++"(q, 1)) == 1)
assert does_raise(Q.popExn, q)
assert (does_raise(Q.popExn, q))
assert (Q.popExn(\"++"(q, 2)) == 2)
assert does_raise(Q.popExn, q)
assert (does_raise(Q.popExn, q))
assert (Q.size(q) == 0)
}

Expand All@@ -58,8 +58,8 @@ let () = {
assert (Q.popExn(q) == 2)
assert (Q.peekExn(q) == 3)
assert (Q.popExn(q) == 3)
assert does_raise(Q.peekExn, q)
assert does_raise(Q.peekExn, q)
assert (does_raise(Q.peekExn, q))
assert (does_raise(Q.peekExn, q))
}

let () = {
Expand All@@ -69,7 +69,7 @@ let () = {
}
Q.clear(q)
assert (Q.size(q) == 0)
assert does_raise(Q.popExn, q)
assert (does_raise(Q.popExn, q))
assert (q == Q.make())
Q.add(q, 42)
assert (Q.popExn(q) == 42)
Expand All@@ -95,19 +95,19 @@ let () = {

let () = {
let q = Q.make()
assert Q.isEmpty(q)
assert (Q.isEmpty(q))
for i in 1 to 10 {
Q.add(q, i)
assert (Q.size(q) == i)
assert !Q.isEmpty(q)
assert (!Q.isEmpty(q))
}
for i in 10 downto 1 {
assert (Q.size(q) == i)
assert !Q.isEmpty(q)
assert (!Q.isEmpty(q))
ignore((Q.popExn(q): int))
}
assert (Q.size(q) == 0)
assert Q.isEmpty(q)
assert (Q.isEmpty(q))
}

let () = {
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -10,7 +10,7 @@ let bench = () => {
)
%time(
for i in 0 to count {
assert N.has(data.contents, i)
assert(N.has(data.contents, i))
}
)
%time(
Expand Down
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
assert !Escape_esmodule.__esModule
assert(!Escape_esmodule.__esModule)
Js.log(Escape_esmodule.__esModule)
Original file line numberDiff line numberDiff line change
Expand Up@@ -101,7 +101,7 @@ let a0 = try %raw(` function (){throw 2} () `) catch {
/* throw is a statement */
| A(x) => x
| Js.Exn.Error(v) => Obj.magic(v)
| _ => assert false
| _ => assert(false)
}

let a1: exn = try %raw(` function (){throw 2} () `) catch {
Expand All@@ -124,7 +124,7 @@ let suites = ref({
_ =>
switch a1 {
| Js.Exn.Error(v) => Eq(Obj.magic(v), 2)
| _ => assert false
| _ => assert(false)
},
),
}
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -13,7 +13,7 @@ let to_int = (x: attr) =>
| Str(_) => -1
| N.Int(a, _) => a
| Int(_, b) => b
| _ => assert false
| _ => assert(false)
}

let suites = {
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -7,10 +7,10 @@ type queue<'a> = {
}
type size
type pp_token
let peek_queue = _ => assert false
let int_of_size = _ => assert false
let take_queue = _ => assert false
let format_pp_token = (_, _) => assert false
let peek_queue = _ => assert(false)
let int_of_size = _ => assert(false)
let take_queue = _ => assert(false)
let format_pp_token = (_, _) => assert(false)
let pp_infinity = 1000000010
type pp_queue_elem = {
mutable elem_size: size,
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -30,13 +30,13 @@ let f3 = ({rank: lhs, _}, {rank: rhs}) =>
/* generate curried version when pattern match against arguments */
switch (lhs, rhs) {
| (Ranked(x), Ranked(y)) => Pervasives.compare(x, y)
| _ => assert false
| _ => assert(false)
}

let f4 = ({rank: lhs, _}, {rank: rhs}) =>
switch (lhs, rhs) {
| (Ranked(x), Ranked(y)) => Pervasives.compare(x, y)
| _ => assert false
| _ => assert(false)
}

/* #995 test case */
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -38,7 +38,7 @@ let rec compare = (context, state, a, b) =>
| (_, Sum(_), _) => 1
| (Gcd(_), _, _) => 1
| (_, Gcd(_), _) => -1
| _ => assert false
| _ => assert(false)
}
let a = Sum(list{sym("a"), Val(Natural(2))})
let b = sym("x")
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -49,4 +49,4 @@ let f3: (. unit) => bool = %raw("()=>true")

let bbbb = f3(.)

assert bbbb
assert(bbbb)
Original file line numberDiff line numberDiff line change
Expand Up@@ -37,8 +37,8 @@ module Make = (G: G) => {
let counter = ref(1)

let rec step2 = (top, rest_of_stack) => {
assert !is_already_processed(top)
assert !is_on_the_stack(top)
assert(!is_already_processed(top))
assert(!is_on_the_stack(top))
H.add(on_the_stack, top, true)
H.add(n_labels, top, counter.contents)
counter := counter.contents + 1
Expand Down
Original file line numberDiff line numberDiff line change
Expand Up@@ -356,7 +356,7 @@ module Make = (Ord: OrderedType) => {
| (_, Node(l2, v2, d2, r2, h2)) =>
let (l1, d1, r1) = split(v2, s1)
concat_or_join(merge(f, l1, l2), v2, f(v2, d1, Some(d2)), merge(f, r1, r2))
| _ => assert false
| _ => assert(false)
}

let rec filter = (p, x) =>
Expand Down
Loading