Skip to content

Commit

Permalink
Merge pull request #497 from moonbitlang/remove_expect
Browse files Browse the repository at this point in the history
internal: remove outdate expect!()
  • Loading branch information
Young-Flash authored Nov 28, 2024
2 parents fd61ae8 + dfc92ec commit 3cf7509
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 24 deletions.
34 changes: 17 additions & 17 deletions crates/moon/tests/test_cases/expect_test.in/lib/hello.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -3,46 +3,46 @@ pub fn hello() -> String {
}

test "basic" {
let buf = Buffer::new()
let buf = @buffer.new()
let n = 123
buf.write_string(n.to_string())
buf.expect!()
inspect!(buf)
}

test "indent" {
let _ = {
let buf = Buffer::new()
let buf = @buffer.new()
let s = "haha"
buf.write_string(s)
buf.expect!()
inspect!(buf)
}
()
}

test "auto_reset" {
let buf = Buffer::new()
let buf = @buffer.new()
let s = "haha"
buf.write_string(s)
buf.expect!()
inspect!(buf)
let s = "123"
buf.write_string(s)
buf.expect!(content="123")
inspect!(buf, content="123")
}

test "multiline-string" {
let buf = Buffer::new()
let buf = @buffer.new()
let s = "1\n2\n3\n"
buf.write_string(s)
buf.expect!()
inspect!(buf)
}

test "multiline-string-2" {
let buf = Buffer::new()
let buf = @buffer.new()
let s =
#|abc
#|def
buf.write_string(s)
buf.expect!(
inspect!(buf,
content=
#|bcd
#|defg
Expand All @@ -51,9 +51,9 @@ test "multiline-string-2" {
}

test "not-empty-expect" {
let buf = Buffer::new()
let buf = @buffer.new()
buf.write_string("123")
buf.expect!(content="1")
inspect!(buf, content="1")
}

test {
Expand Down Expand Up @@ -128,15 +128,15 @@ test {
}

test {
let buf = Buffer::new()
let buf = @buffer.new()
buf.write_string("just\ntest")
buf.expect!()
inspect!(buf)
}

test "hello" {
let buf = Buffer::new()
let buf = @buffer.new()
buf.write_string("just\ntest")
buf.expect!(content="")
inspect!(buf, content="")
}

fn actual() -> String {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
test "hello" {
let buf = Buffer::new()
let buf = @buffer.new()
buf.write_string("just\ntest")
buf.expect!()
inspect!(buf)
}

test "not-buf" {
let notbuf = Buffer::new()
let notbuf = @buffer.new()
notbuf.write_string("haha")
notbuf.expect!()
inspect!(notbuf)
}
2 changes: 1 addition & 1 deletion crates/moon/tests/test_cases/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2246,7 +2246,7 @@ fn test_expect_test() -> anyhow::Result<()> {
assert!(out.contains("Total tests: 30, passed: 30, failed: 0."));
let out = std::fs::read_to_string(tmp_dir_path.as_ref().join("lib").join("hello_wbtest.mbt"))
.unwrap();
assert!(out.contains(r#"notbuf.expect!(content="haha")"#));
assert!(out.contains(r#"inspect!(notbuf, content="haha")"#));
Ok(())
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ fn string_read_char(handle : StringReadHandle) -> Int = "__moonbit_fs_unstable"
fn finish_read_string(handle : StringReadHandle) = "__moonbit_fs_unstable" "finish_read_string"

pub fn string_from_extern(e : ExternString) -> String {
let buf = Buffer::new()
let buf = @buffer.new()
let handle = begin_read_string(e)
while true {
let ch = string_read_char(handle)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ fn string_read_char(handle : StringReadHandle) -> Int = "__moonbit_fs_unstable"
fn finish_read_string(handle : StringReadHandle) = "__moonbit_fs_unstable" "finish_read_string"

fn string_from_extern(e : ExternString) -> String {
let buf = Buffer::new()
let buf = @buffer.new()
let handle = begin_read_string(e)
while true {
let ch = string_read_char(handle)
Expand Down

0 comments on commit 3cf7509

Please sign in to comment.