1// +build js
2
3package reflect_test
4
5import (
6	"math"
7	"reflect"
8	"testing"
9)
10
11func TestAlignment(t *testing.T) {
12	t.Skip()
13}
14
15func TestSliceOverflow(t *testing.T) {
16	t.Skip()
17}
18
19func TestFuncLayout(t *testing.T) {
20	t.Skip()
21}
22
23func TestArrayOfDirectIface(t *testing.T) {
24	t.Skip()
25}
26
27func TestTypelinksSorted(t *testing.T) {
28	t.Skip()
29}
30
31func TestGCBits(t *testing.T) {
32	t.Skip()
33}
34
35func TestChanAlloc(t *testing.T) {
36	t.Skip()
37}
38
39func TestNameBytesAreAligned(t *testing.T) {
40	t.Skip()
41}
42
43func TestOffsetLock(t *testing.T) {
44	t.Skip()
45}
46
47func TestSelectOnInvalid(t *testing.T) {
48	reflect.Select([]reflect.SelectCase{
49		{
50			Dir:  reflect.SelectRecv,
51			Chan: reflect.Value{},
52		}, {
53			Dir:  reflect.SelectSend,
54			Chan: reflect.Value{},
55			Send: reflect.ValueOf(1),
56		}, {
57			Dir: reflect.SelectDefault,
58		},
59	})
60}
61
62func TestStructOfFieldName(t *testing.T) {
63	t.Skip("StructOf")
64}
65
66func TestStructOf(t *testing.T) {
67	t.Skip("StructOf")
68}
69
70func TestStructOfExportRules(t *testing.T) {
71	t.Skip("StructOf")
72}
73
74func TestStructOfGC(t *testing.T) {
75	t.Skip("StructOf")
76}
77
78func TestStructOfAlg(t *testing.T) {
79	t.Skip("StructOf")
80}
81
82func TestStructOfGenericAlg(t *testing.T) {
83	t.Skip("StructOf")
84}
85
86func TestStructOfDirectIface(t *testing.T) {
87	t.Skip("StructOf")
88}
89
90func TestStructOfWithInterface(t *testing.T) {
91	t.Skip("StructOf")
92}
93
94var deepEqualTests = []DeepEqualTest{
95	// Equalities
96	{nil, nil, true},
97	{1, 1, true},
98	{int32(1), int32(1), true},
99	{0.5, 0.5, true},
100	{float32(0.5), float32(0.5), true},
101	{"hello", "hello", true},
102	{make([]int, 10), make([]int, 10), true},
103	{&[3]int{1, 2, 3}, &[3]int{1, 2, 3}, true},
104	{Basic{1, 0.5}, Basic{1, 0.5}, true},
105	{error(nil), error(nil), true},
106	{map[int]string{1: "one", 2: "two"}, map[int]string{2: "two", 1: "one"}, true},
107	{fn1, fn2, true},
108
109	// Inequalities
110	{1, 2, false},
111	{int32(1), int32(2), false},
112	{0.5, 0.6, false},
113	{float32(0.5), float32(0.6), false},
114	{"hello", "hey", false},
115	{make([]int, 10), make([]int, 11), false},
116	{&[3]int{1, 2, 3}, &[3]int{1, 2, 4}, false},
117	{Basic{1, 0.5}, Basic{1, 0.6}, false},
118	{Basic{1, 0}, Basic{2, 0}, false},
119	{map[int]string{1: "one", 3: "two"}, map[int]string{2: "two", 1: "one"}, false},
120	{map[int]string{1: "one", 2: "txo"}, map[int]string{2: "two", 1: "one"}, false},
121	{map[int]string{1: "one"}, map[int]string{2: "two", 1: "one"}, false},
122	{map[int]string{2: "two", 1: "one"}, map[int]string{1: "one"}, false},
123	{nil, 1, false},
124	{1, nil, false},
125	{fn1, fn3, false},
126	{fn3, fn3, false},
127	{[][]int{{1}}, [][]int{{2}}, false},
128	{math.NaN(), math.NaN(), false},
129	{&[1]float64{math.NaN()}, &[1]float64{math.NaN()}, false},
130	{&[1]float64{math.NaN()}, self{}, true},
131	{[]float64{math.NaN()}, []float64{math.NaN()}, false},
132	{[]float64{math.NaN()}, self{}, true},
133	{map[float64]float64{math.NaN(): 1}, map[float64]float64{1: 2}, false},
134	{map[float64]float64{math.NaN(): 1}, self{}, true},
135
136	// Nil vs empty: not the same.
137	{[]int{}, []int(nil), false},
138	{[]int{}, []int{}, true},
139	{[]int(nil), []int(nil), true},
140	{map[int]int{}, map[int]int(nil), false},
141	{map[int]int{}, map[int]int{}, true},
142	{map[int]int(nil), map[int]int(nil), true},
143
144	// Mismatched types
145	{1, 1.0, false},
146	{int32(1), int64(1), false},
147	{0.5, "hello", false},
148	{[]int{1, 2, 3}, [3]int{1, 2, 3}, false},
149	{&[3]interface{}{1, 2, 4}, &[3]interface{}{1, 2, "s"}, false},
150	{Basic{1, 0.5}, NotBasic{1, 0.5}, false},
151	{map[uint]string{1: "one", 2: "two"}, map[int]string{2: "two", 1: "one"}, false},
152
153	// Possible loops.
154	{&loop1, &loop1, true},
155	//{&loop1, &loop2, true}, // TODO: Fix.
156	{&loopy1, &loopy1, true},
157	//{&loopy1, &loopy2, true}, // TODO: Fix.
158}
159
160// TODO: Fix this. See https://github.com/gopherjs/gopherjs/issues/763.
161func TestIssue22073(t *testing.T) {
162	m := reflect.ValueOf(NonExportedFirst(0)).Method(0)
163
164	if got := m.Type().NumOut(); got != 0 {
165		t.Errorf("NumOut: got %v, want 0", got)
166	}
167
168	// TODO: Fix this. The call below fails with:
169	//
170	// 	var $call = function(fn, rcvr, args) { return fn.apply(rcvr, args); };
171	// 	                                                 ^
172	// 	TypeError: Cannot read property 'apply' of undefined
173
174	// Shouldn't panic.
175	//m.Call(nil)
176}
177
178func TestCallReturnsEmpty(t *testing.T) {
179	t.Skip("test uses runtime.SetFinalizer, which is not supported by GopherJS")
180}
181
182func init() {
183	// TODO: This is a failure in 1.11, try to determine the cause and fix.
184	typeTests = append(typeTests[:31], typeTests[32:]...) // skip test case #31
185}
186