-
-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
GD-546: Allow to test un-typed values by
assert_that
(#547)
# Why see #546 # What - do allow all Variant types for `is_equal` and `is_not_equal` when using the un-typed `assert_that` - changed the fixed typed `is_equal` and `is_not_equal` to accept Variant type
- Loading branch information
1 parent
fac168f
commit 3edc885
Showing
11 changed files
with
170 additions
and
42 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
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
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
116 changes: 116 additions & 0 deletions
116
addons/gdUnit4/test/asserts/GdUnitVariantAssertThatTest.gd
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,116 @@ | ||
extends GdUnitTestSuite | ||
|
||
|
||
func test_is_equal_success() -> void: | ||
assert_that(3 as Variant).is_equal(3) | ||
assert_that(3.14 as Variant).is_equal(3.14) | ||
assert_that("3" as Variant).is_equal("3") | ||
assert_that(true as Variant).is_equal(true) | ||
assert_that(Vector2.ONE as Variant).is_equal(Vector2.ONE) | ||
assert_that({a=1, b=2} as Variant).is_equal({a=1, b=2}) | ||
assert_that([1,2,3] as Variant).is_equal([1,2,3]) | ||
assert_that(RefCounted.new() as Variant).is_equal(RefCounted.new()) | ||
|
||
|
||
func test_is_equal_fail() -> void: | ||
# bool vs int | ||
assert_failure(func()->void: | ||
assert_that(true as Variant).is_equal(1))\ | ||
.is_failed() | ||
|
||
# bool vs string | ||
assert_failure(func()->void: | ||
assert_that(true as Variant).is_equal("true"))\ | ||
.is_failed() | ||
|
||
# int vs string | ||
assert_failure(func()->void: | ||
assert_that(3 as Variant).is_equal("3"))\ | ||
.is_failed() | ||
|
||
# float vs string | ||
assert_failure(func()->void: | ||
assert_that(3.14 as Variant).is_equal("3.14"))\ | ||
.is_failed() | ||
|
||
# string vs int | ||
assert_failure(func()->void: | ||
assert_that("3" as Variant).is_equal(3))\ | ||
.is_failed() | ||
|
||
# string vs float | ||
assert_failure(func()->void: | ||
assert_that("3.14" as Variant).is_equal(3.14))\ | ||
.is_failed() | ||
|
||
# vector vs string | ||
assert_failure(func()->void: | ||
assert_that(Vector2.ONE as Variant).is_equal("ONE"))\ | ||
.is_failed() | ||
|
||
# dictionary vs string | ||
assert_failure(func()->void: | ||
assert_that({a=1, b=2} as Variant).is_equal("FOO"))\ | ||
.is_failed() | ||
|
||
# array vs string | ||
assert_failure(func()->void: | ||
assert_that([1,2,3] as Variant).is_equal("FOO"))\ | ||
.is_failed() | ||
|
||
# object vs string | ||
assert_failure(func()->void: | ||
assert_that(RefCounted.new() as Variant).is_equal("FOO"))\ | ||
.is_failed() | ||
|
||
|
||
func test_is_not_equal_success() -> void: | ||
assert_that(3 as Variant).is_not_equal(4) | ||
assert_that(3.14 as Variant).is_not_equal(3.15) | ||
assert_that("3" as Variant).is_not_equal("33") | ||
assert_that(true as Variant).is_not_equal(false) | ||
assert_that(Vector2.ONE as Variant).is_not_equal(Vector2.UP) | ||
assert_that({a=1, b=2} as Variant).is_not_equal({a=1, b=3}) | ||
assert_that([1,2,3] as Variant).is_not_equal([1,2,4]) | ||
assert_that(RefCounted.new() as Variant).is_not_equal(null) | ||
|
||
|
||
func test_is_not_equal_fail() -> void: | ||
# bool vs int | ||
assert_failure(func()->void: | ||
assert_that(true as Variant).is_not_equal(true) | ||
)\ | ||
.is_failed() | ||
|
||
|
||
assert_failure(func()->void: | ||
assert_that(3 as Variant).is_not_equal(3))\ | ||
.is_failed() | ||
|
||
assert_failure(func()->void: | ||
assert_that(3.14 as Variant).is_not_equal(3.14))\ | ||
.is_failed() | ||
|
||
assert_failure(func()->void: | ||
assert_that("3" as Variant).is_not_equal("3"))\ | ||
.is_failed() | ||
|
||
# vector vs string | ||
assert_failure(func()->void: | ||
assert_that(Vector2.ONE as Variant).is_not_equal(Vector2.ONE))\ | ||
.is_failed() | ||
|
||
# dictionary vs string | ||
assert_failure(func()->void: | ||
assert_that({a=1, b=2} as Variant).is_not_equal({a=1, b=2}))\ | ||
.is_failed() | ||
|
||
# array vs string | ||
assert_failure(func()->void: | ||
assert_that([1,2,3] as Variant).is_not_equal([1,2,3]))\ | ||
.is_failed() | ||
|
||
# object vs string | ||
assert_failure(func()->void: | ||
assert_that(RefCounted.new() as Variant).is_not_equal(RefCounted.new()))\ | ||
.is_failed() |
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