MCPcopy
hub / github.com/gopherjs/gopherjs / TestIssue733

Function TestIssue733

tests/numeric_test.go:103–124  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

101}
102
103func TestIssue733(t *testing.T) {
104 if runtime.GOOS != "js" {
105 t.Skip("test uses GopherJS-specific features")
106 }
107
108 t.Run("sign", func(t *testing.T) {
109 f := float64(-1)
110 i := uint32(f)
111 underlying := js.InternalObject(i).Float() // Get the raw JS number behind i.
112 if want := float64(4294967295); underlying != want {
113 t.Errorf("Got: uint32(float64(%v)) = %v. Want: %v.", f, underlying, want)
114 }
115 })
116 t.Run("truncation", func(t *testing.T) {
117 f := float64(300)
118 i := uint8(f)
119 underlying := js.InternalObject(i).Float() // Get the raw JS number behind i.
120 if want := float64(44); underlying != want {
121 t.Errorf("Got: uint32(float64(%v)) = %v. Want: %v.", f, underlying, want)
122 }
123 })
124}
125
126// Test_32BitEnvironment tests that GopherJS behaves correctly
127// as a 32-bit environment for integers. To simulate a 32 bit environment

Callers

nothing calls this directly

Calls 2

InternalObjectFunction · 0.92
FloatMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…