umx_compiler

UMX virtual machine "Monkey" interpreter / bytecode compiler
git clone git://bsandro.tech/umx_compiler
Log | Files | Refs | README | LICENSE

object_test.go (506B)


      1 package object
      2 
      3 import (
      4 	"testing"
      5 )
      6 
      7 func TestStringHashKey(t *testing.T) {
      8 	hello1 := &String{Value: "hello"}
      9 	hello2 := &String{Value: "hello"}
     10 	diff1 := &String{Value: "world"}
     11 	diff2 := &Boolean{Value: false}
     12 	if hello1.HashKey() != hello2.HashKey() {
     13 		t.Errorf("equal strings have different hashes")
     14 	}
     15 	if diff1.HashKey() == hello1.HashKey() {
     16 		t.Errorf("different strings have same hashes")
     17 	}
     18 	if diff1.HashKey() == diff2.HashKey() {
     19 		t.Errorf("different objects/types have same hashes")
     20 	}
     21 }