-
-
Notifications
You must be signed in to change notification settings - Fork 310
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
pkg/eval/vals: Test that structmaps are treated like maps by CmpTotal.
- Loading branch information
Showing
1 changed file
with
21 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,27 @@ | ||
package vals | ||
|
||
import "testing" | ||
import ( | ||
"testing" | ||
|
||
"src.elv.sh/pkg/tt" | ||
) | ||
|
||
func TestCmp(t *testing.T) { | ||
// Cmp is tested by tests of the Elvish compare command. | ||
} | ||
|
||
func TestCmpTotal_StructMap(t *testing.T) { | ||
// CmpTotal should pretend that structmaps are maps too. Since maps don't | ||
// have an internal ordering, comparing a structmap to another structmap or | ||
// to a map should always return CmpEqual, like comparing two maps. | ||
// | ||
// This is not covered by tests of the Elvish compare command because Elvish | ||
// code are not supposed to know which values are actually structmaps. | ||
x := testStructMap{} | ||
y := testStructMap2{} | ||
z := EmptyMap | ||
tt.Test(t, tt.Fn("CmpTotal", CmpTotal), tt.Table{ | ||
tt.Args(x, y).Rets(CmpEqual), | ||
tt.Args(x, z).Rets(CmpEqual), | ||
}) | ||
} |