-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🎨 Separate assertions and expectations
- Loading branch information
Showing
7 changed files
with
63 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
module vest | ||
|
||
pub fn assert_nil(expected voidptr) { | ||
assert isnil(expected), '${expected} should be nil' | ||
} | ||
|
||
pub fn assert_true(expected bool) { | ||
assert expected != true, '${expected} should be true' | ||
} | ||
|
||
pub fn assert_false(expected bool) { | ||
assert expected == false, '${expected} should be false' | ||
} | ||
|
||
pub fn assert_equal[E, P](expected E, provided P) { | ||
assert expected == provided, '${expected} should be equal to ${provided}' | ||
} | ||
|
||
pub fn assert_is[E, T](expected E) { | ||
assert expected is T, '${expected} should be of type ${T}' | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
module vest | ||
|
||
@[params] | ||
struct Expectation[E] { | ||
expected E | ||
} | ||
|
||
pub fn expect[E](expected E) Expectation[E] { | ||
return Expectation[E]{expected} | ||
} | ||
|
||
pub fn expect_bool(expected bool) Expectation[bool] { | ||
return Expectation{expected} | ||
} | ||
|
||
pub fn (expectation Expectation[voidptr]) to_be_nil() Expectation[voidptr] { | ||
assert_nil(expectation.expected) | ||
return expectation | ||
} | ||
|
||
pub fn (expectation Expectation[bool]) to_be_true() Expectation[bool] { | ||
assert_true(expectation.expected) | ||
return expectation | ||
} | ||
|
||
pub fn (expectation Expectation[bool]) to_be_false() Expectation[bool] { | ||
assert_false(expectation.expected) | ||
return expectation | ||
} | ||
|
||
pub fn (expectation Expectation[E]) to_equal[P](provided P) Expectation[E] { | ||
assert_equal(expectation.expected, provided) | ||
return expectation | ||
} | ||
|
||
pub fn (expectation Expectation[E]) assert_is[T]() Expectation[E] { | ||
assert_is[T](expectation.expected) | ||
return expectation | ||
} |
This file was deleted.
Oops, something went wrong.