src.elv.sh@v0.21.0-dev.0.20240515223629-06979efb9a2a/pkg/eval/vals/cmp_test.go (about)

     1  package vals
     2  
     3  import (
     4  	"testing"
     5  
     6  	"src.elv.sh/pkg/tt"
     7  )
     8  
     9  func TestCmp(t *testing.T) {
    10  	// Cmp is tested by tests of the Elvish compare command.
    11  }
    12  
    13  func TestCmpTotal_StructMap(t *testing.T) {
    14  	// CmpTotal should pretend that structmaps are maps too. Since maps don't
    15  	// have an internal ordering, comparing a structmap to another structmap or
    16  	// to a map should always return CmpEqual, like comparing two maps.
    17  	//
    18  	// This is not covered by tests of the Elvish compare command because Elvish
    19  	// code are not supposed to know which values are actually structmaps.
    20  	x := testStructMap{}
    21  	y := testStructMap2{}
    22  	z := EmptyMap
    23  	tt.Test(t, CmpTotal,
    24  		tt.Args(x, y).Rets(CmpEqual),
    25  		tt.Args(x, z).Rets(CmpEqual),
    26  	)
    27  }