-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
76 additions
and
32 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
43 changes: 43 additions & 0 deletions
43
src/test/resources/regressions/features/ghost_field/ghost-field-comparison-simple02.gobra
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,43 @@ | ||
// Any copyright is dedicated to the Public Domain. | ||
// http://creativecommons.org/publicdomain/zero/1.0/ | ||
|
||
// tests that Gobra correctly excludes ghost fields of nested structs when comparing structs using the standard Go comparison | ||
|
||
package GhostFieldComparisonSimple02 | ||
|
||
type Test struct { | ||
n NestedStruct | ||
} | ||
|
||
type NestedStruct struct { | ||
actualField int | ||
ghost ghostField int | ||
} | ||
|
||
decreases | ||
func foo() { | ||
t1 := Test{NestedStruct{0, 0}} | ||
t2 := Test{NestedStruct{0, 42}} | ||
t3 := Test{NestedStruct{0, 42}} | ||
assert t1 == t2 // actual comparison, i.e., ghost fields are ignored | ||
assert t2 === t3 // ghost comparison | ||
assert t1 !== t2 // ghost comparison | ||
|
||
//:: ExpectedOutput(assert_error:assertion_error) | ||
assert false | ||
} | ||
|
||
// behavior is the same independent of ghost/actual context | ||
ghost | ||
decreases | ||
func ghostFoo() { | ||
t1 := Test{NestedStruct{0, 0}} | ||
t2 := Test{NestedStruct{0, 42}} | ||
t3 := Test{NestedStruct{0, 42}} | ||
assert t1 == t2 // actual comparison, i.e., ghost fields are ignored | ||
assert t2 === t3 // ghost comparison | ||
assert t1 !== t2 // ghost comparison | ||
|
||
//:: ExpectedOutput(assert_error:assertion_error) | ||
assert false | ||
} |