-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
defines '==' for ghost structs to be the same as '==='
- Loading branch information
Showing
11 changed files
with
95 additions
and
22 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
21 changes: 21 additions & 0 deletions
21
src/test/resources/regressions/features/ghost_type/ghost-struct-comparison-fail01.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,21 @@ | ||
// Any copyright is dedicated to the Public Domain. | ||
// http://creativecommons.org/publicdomain/zero/1.0/ | ||
|
||
package GhostStructComparison01 | ||
|
||
// a ghost struct cannot be compared to an actual struct | ||
|
||
ghost type GhostStruct struct { | ||
f int | ||
} | ||
|
||
type ActualStruct struct { | ||
ghost f int | ||
} | ||
|
||
func foo(x ActualStruct, ghost y GhostStruct) { | ||
//:: ExpectedOutput(type_error) | ||
assert x == y | ||
//:: ExpectedOutput(type_error) | ||
assert x === y | ||
} |
20 changes: 20 additions & 0 deletions
20
src/test/resources/regressions/features/ghost_type/ghost-struct-comparison-simple01.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,20 @@ | ||
// Any copyright is dedicated to the Public Domain. | ||
// http://creativecommons.org/publicdomain/zero/1.0/ | ||
|
||
package GhostStructComparison01 | ||
|
||
// when comparing ghost structs, ghost equality should be used. I.e., `==` behaves like `===`. | ||
|
||
ghost type GhostStruct struct { | ||
f int | ||
} | ||
|
||
func test1(ghost x, y GhostStruct) { | ||
//:: ExpectedOutput(assert_error:assertion_error) | ||
assert x == y | ||
} | ||
|
||
func test2(ghost x, y GhostStruct) { | ||
//:: ExpectedOutput(assert_error:assertion_error) | ||
assert x === y | ||
} |
29 changes: 29 additions & 0 deletions
29
src/test/resources/regressions/features/maps/maps-fail3.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,29 @@ | ||
// Any copyright is dedicated to the Public Domain. | ||
// http://creativecommons.org/publicdomain/zero/1.0/ | ||
|
||
package mapsfail3 | ||
|
||
// tests that neither structs with ghost fields, ghost structs, nor other ghost types can serve as a map's key | ||
|
||
type ActualStruct struct { | ||
ghost f int | ||
} | ||
|
||
ghost type GhostStruct struct { | ||
f int | ||
} | ||
|
||
//:: ExpectedOutput(type_error) | ||
func test1(m map[ActualStruct]int) int { | ||
return 42 | ||
} | ||
|
||
//:: ExpectedOutput(type_error) | ||
func test2(m map[GhostStruct]int) int { | ||
return 42 | ||
} | ||
|
||
//:: ExpectedOutput(type_error) | ||
func test3(m map[seq[int]]int) int { | ||
return 42 | ||
} |