Skip to content

Commit

Permalink
update test
Browse files Browse the repository at this point in the history
  • Loading branch information
sigmaSd committed Oct 18, 2021
1 parent c02d606 commit e654d7d
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions tests/irust_bot_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@ def send(op):
child.send(f"{op}\r")


def assert_eq(op, val):
def assert_eq(op, val, sinkN=0):
print(f"[testing] `{op}` => `{val}`")
send(op)
sink(sinkN)
out = child.readline().strip().decode("utf-8")
if out == op:
print("Race condition detected, test needs to be restarted (a couple of retries might be needed)")
Expand All @@ -39,26 +40,26 @@ def assert_eq(op, val):
assert_eq(":add regex", "Ok!")
assert_eq('regex::Regex::new("a.*a").unwrap()', "a.*a")

assert_eq("z", "cannot find value `z` in this scope\x1b[0m")
assert_eq("z", "cannot find value `z` in this scope\x1b[0m", sinkN=1)
sink(4)

assert_eq("1+2", "3")
assert_eq("1+2", "3", sinkN=1)

send('let a = "hello";')
assert_eq(':type a', "`&str`")
assert_eq(':type a', "`&str`", sinkN=2)

send("""fn fact(n: usize) -> usize {
match n {
1 => 1,
n => n * fact(n-1)
}
}""")
assert_eq("fact(4)", "24")
assert_eq("fact(4)", "24", sinkN=1)

assert_eq(':toolchain nightly', "Ok!")
assert_eq(':toolchain nightly', "Ok!", sinkN=1)
send('#![feature(decl_macro)]')
send('macro inc($n: expr) {$n + 1}')
assert_eq('inc!({1+1})', '3')
assert_eq('inc!({1+1})', '3', sinkN=2)


print("All tests passed!")

0 comments on commit e654d7d

Please sign in to comment.