author | sundar |
Wed, 06 May 2015 20:04:42 +0530 | |
changeset 30394 | 72a59e4dffea |
parent 29133 | 1cd7d8af99ba |
child 31925 | 85c87bc2f1f3 |
permissions | -rw-r--r-- |
29133
1cd7d8af99ba
8072426: Can't compare Java objects to strings or numbers
attila
parents:
diff
changeset
|
1 |
/* |
1cd7d8af99ba
8072426: Can't compare Java objects to strings or numbers
attila
parents:
diff
changeset
|
2 |
* Copyright (c) 2015 Oracle and/or its affiliates. All rights reserved. |
1cd7d8af99ba
8072426: Can't compare Java objects to strings or numbers
attila
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
1cd7d8af99ba
8072426: Can't compare Java objects to strings or numbers
attila
parents:
diff
changeset
|
4 |
* |
1cd7d8af99ba
8072426: Can't compare Java objects to strings or numbers
attila
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
1cd7d8af99ba
8072426: Can't compare Java objects to strings or numbers
attila
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
1cd7d8af99ba
8072426: Can't compare Java objects to strings or numbers
attila
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
1cd7d8af99ba
8072426: Can't compare Java objects to strings or numbers
attila
parents:
diff
changeset
|
8 |
* |
1cd7d8af99ba
8072426: Can't compare Java objects to strings or numbers
attila
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
1cd7d8af99ba
8072426: Can't compare Java objects to strings or numbers
attila
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
1cd7d8af99ba
8072426: Can't compare Java objects to strings or numbers
attila
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
1cd7d8af99ba
8072426: Can't compare Java objects to strings or numbers
attila
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
1cd7d8af99ba
8072426: Can't compare Java objects to strings or numbers
attila
parents:
diff
changeset
|
13 |
* accompanied this code). |
1cd7d8af99ba
8072426: Can't compare Java objects to strings or numbers
attila
parents:
diff
changeset
|
14 |
* |
1cd7d8af99ba
8072426: Can't compare Java objects to strings or numbers
attila
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
1cd7d8af99ba
8072426: Can't compare Java objects to strings or numbers
attila
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
1cd7d8af99ba
8072426: Can't compare Java objects to strings or numbers
attila
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
1cd7d8af99ba
8072426: Can't compare Java objects to strings or numbers
attila
parents:
diff
changeset
|
18 |
* |
1cd7d8af99ba
8072426: Can't compare Java objects to strings or numbers
attila
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
1cd7d8af99ba
8072426: Can't compare Java objects to strings or numbers
attila
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
1cd7d8af99ba
8072426: Can't compare Java objects to strings or numbers
attila
parents:
diff
changeset
|
21 |
* questions. |
1cd7d8af99ba
8072426: Can't compare Java objects to strings or numbers
attila
parents:
diff
changeset
|
22 |
*/ |
1cd7d8af99ba
8072426: Can't compare Java objects to strings or numbers
attila
parents:
diff
changeset
|
23 |
|
1cd7d8af99ba
8072426: Can't compare Java objects to strings or numbers
attila
parents:
diff
changeset
|
24 |
/** |
1cd7d8af99ba
8072426: Can't compare Java objects to strings or numbers
attila
parents:
diff
changeset
|
25 |
* JDK-8072426: Can't compare Java objects to strings or numbers |
1cd7d8af99ba
8072426: Can't compare Java objects to strings or numbers
attila
parents:
diff
changeset
|
26 |
* |
1cd7d8af99ba
8072426: Can't compare Java objects to strings or numbers
attila
parents:
diff
changeset
|
27 |
* @test |
1cd7d8af99ba
8072426: Can't compare Java objects to strings or numbers
attila
parents:
diff
changeset
|
28 |
* @run |
1cd7d8af99ba
8072426: Can't compare Java objects to strings or numbers
attila
parents:
diff
changeset
|
29 |
*/ |
1cd7d8af99ba
8072426: Can't compare Java objects to strings or numbers
attila
parents:
diff
changeset
|
30 |
|
1cd7d8af99ba
8072426: Can't compare Java objects to strings or numbers
attila
parents:
diff
changeset
|
31 |
Assert.assertTrue(java.math.RoundingMode.UP == "UP"); |
1cd7d8af99ba
8072426: Can't compare Java objects to strings or numbers
attila
parents:
diff
changeset
|
32 |
|
1cd7d8af99ba
8072426: Can't compare Java objects to strings or numbers
attila
parents:
diff
changeset
|
33 |
var JSObject = Java.type("jdk.nashorn.api.scripting.JSObject"); |
1cd7d8af99ba
8072426: Can't compare Java objects to strings or numbers
attila
parents:
diff
changeset
|
34 |
|
1cd7d8af99ba
8072426: Can't compare Java objects to strings or numbers
attila
parents:
diff
changeset
|
35 |
// Adds an "isFunction" member to the JSObject that returns the specified value |
1cd7d8af99ba
8072426: Can't compare Java objects to strings or numbers
attila
parents:
diff
changeset
|
36 |
function addIsFunction(isFunction, obj) { |
1cd7d8af99ba
8072426: Can't compare Java objects to strings or numbers
attila
parents:
diff
changeset
|
37 |
obj.isFunction = function() { |
1cd7d8af99ba
8072426: Can't compare Java objects to strings or numbers
attila
parents:
diff
changeset
|
38 |
return isFunction; |
1cd7d8af99ba
8072426: Can't compare Java objects to strings or numbers
attila
parents:
diff
changeset
|
39 |
}; |
1cd7d8af99ba
8072426: Can't compare Java objects to strings or numbers
attila
parents:
diff
changeset
|
40 |
return obj; |
1cd7d8af99ba
8072426: Can't compare Java objects to strings or numbers
attila
parents:
diff
changeset
|
41 |
} |
1cd7d8af99ba
8072426: Can't compare Java objects to strings or numbers
attila
parents:
diff
changeset
|
42 |
|
1cd7d8af99ba
8072426: Can't compare Java objects to strings or numbers
attila
parents:
diff
changeset
|
43 |
function makeJSObjectConstantFunction(value) { |
1cd7d8af99ba
8072426: Can't compare Java objects to strings or numbers
attila
parents:
diff
changeset
|
44 |
return new JSObject(addIsFunction(true, { |
1cd7d8af99ba
8072426: Can't compare Java objects to strings or numbers
attila
parents:
diff
changeset
|
45 |
call: function() { |
1cd7d8af99ba
8072426: Can't compare Java objects to strings or numbers
attila
parents:
diff
changeset
|
46 |
return value; |
1cd7d8af99ba
8072426: Can't compare Java objects to strings or numbers
attila
parents:
diff
changeset
|
47 |
} |
1cd7d8af99ba
8072426: Can't compare Java objects to strings or numbers
attila
parents:
diff
changeset
|
48 |
})); |
1cd7d8af99ba
8072426: Can't compare Java objects to strings or numbers
attila
parents:
diff
changeset
|
49 |
} |
1cd7d8af99ba
8072426: Can't compare Java objects to strings or numbers
attila
parents:
diff
changeset
|
50 |
|
1cd7d8af99ba
8072426: Can't compare Java objects to strings or numbers
attila
parents:
diff
changeset
|
51 |
function makeJSObjectWithMembers(mapping) { |
1cd7d8af99ba
8072426: Can't compare Java objects to strings or numbers
attila
parents:
diff
changeset
|
52 |
return new JSObject({ |
1cd7d8af99ba
8072426: Can't compare Java objects to strings or numbers
attila
parents:
diff
changeset
|
53 |
getMember: function(name) { |
1cd7d8af99ba
8072426: Can't compare Java objects to strings or numbers
attila
parents:
diff
changeset
|
54 |
Assert.assertTrue(mapping.hasOwnProperty(name)); |
1cd7d8af99ba
8072426: Can't compare Java objects to strings or numbers
attila
parents:
diff
changeset
|
55 |
return mapping[name]; |
1cd7d8af99ba
8072426: Can't compare Java objects to strings or numbers
attila
parents:
diff
changeset
|
56 |
}, |
1cd7d8af99ba
8072426: Can't compare Java objects to strings or numbers
attila
parents:
diff
changeset
|
57 |
toNumber: function() { |
1cd7d8af99ba
8072426: Can't compare Java objects to strings or numbers
attila
parents:
diff
changeset
|
58 |
// toNumber no longer invoked |
1cd7d8af99ba
8072426: Can't compare Java objects to strings or numbers
attila
parents:
diff
changeset
|
59 |
Assert.fail(); |
1cd7d8af99ba
8072426: Can't compare Java objects to strings or numbers
attila
parents:
diff
changeset
|
60 |
} |
1cd7d8af99ba
8072426: Can't compare Java objects to strings or numbers
attila
parents:
diff
changeset
|
61 |
}); |
1cd7d8af99ba
8072426: Can't compare Java objects to strings or numbers
attila
parents:
diff
changeset
|
62 |
} |
1cd7d8af99ba
8072426: Can't compare Java objects to strings or numbers
attila
parents:
diff
changeset
|
63 |
|
1cd7d8af99ba
8072426: Can't compare Java objects to strings or numbers
attila
parents:
diff
changeset
|
64 |
// Test JSObjectLinker toInt32/toLong/toNumber |
1cd7d8af99ba
8072426: Can't compare Java objects to strings or numbers
attila
parents:
diff
changeset
|
65 |
function testNumericJSObject(kind, value) { |
1cd7d8af99ba
8072426: Can't compare Java objects to strings or numbers
attila
parents:
diff
changeset
|
66 |
var obj = makeJSObjectWithMembers({ |
1cd7d8af99ba
8072426: Can't compare Java objects to strings or numbers
attila
parents:
diff
changeset
|
67 |
valueOf: makeJSObjectConstantFunction(value) |
1cd7d8af99ba
8072426: Can't compare Java objects to strings or numbers
attila
parents:
diff
changeset
|
68 |
}); |
1cd7d8af99ba
8072426: Can't compare Java objects to strings or numbers
attila
parents:
diff
changeset
|
69 |
|
1cd7d8af99ba
8072426: Can't compare Java objects to strings or numbers
attila
parents:
diff
changeset
|
70 |
if (kind === "double") { |
1cd7d8af99ba
8072426: Can't compare Java objects to strings or numbers
attila
parents:
diff
changeset
|
71 |
// There's no assertEquals(double actual, double expected). There's only |
1cd7d8af99ba
8072426: Can't compare Java objects to strings or numbers
attila
parents:
diff
changeset
|
72 |
// assertEquals(double actual, double expected, double delta). |
1cd7d8af99ba
8072426: Can't compare Java objects to strings or numbers
attila
parents:
diff
changeset
|
73 |
Assert["assertEquals(double,double,double)"](value, obj, 0); |
1cd7d8af99ba
8072426: Can't compare Java objects to strings or numbers
attila
parents:
diff
changeset
|
74 |
} else { |
1cd7d8af99ba
8072426: Can't compare Java objects to strings or numbers
attila
parents:
diff
changeset
|
75 |
Assert["assertEquals(" + kind + ", " + kind + ")"](value, obj); |
1cd7d8af99ba
8072426: Can't compare Java objects to strings or numbers
attila
parents:
diff
changeset
|
76 |
} |
1cd7d8af99ba
8072426: Can't compare Java objects to strings or numbers
attila
parents:
diff
changeset
|
77 |
Assert.assertTrue(value == Number(obj)); |
1cd7d8af99ba
8072426: Can't compare Java objects to strings or numbers
attila
parents:
diff
changeset
|
78 |
} |
1cd7d8af99ba
8072426: Can't compare Java objects to strings or numbers
attila
parents:
diff
changeset
|
79 |
testNumericJSObject("int", 42); |
1cd7d8af99ba
8072426: Can't compare Java objects to strings or numbers
attila
parents:
diff
changeset
|
80 |
testNumericJSObject("long", 4294967296); |
1cd7d8af99ba
8072426: Can't compare Java objects to strings or numbers
attila
parents:
diff
changeset
|
81 |
testNumericJSObject("double", 1.2); |
1cd7d8af99ba
8072426: Can't compare Java objects to strings or numbers
attila
parents:
diff
changeset
|
82 |
|
1cd7d8af99ba
8072426: Can't compare Java objects to strings or numbers
attila
parents:
diff
changeset
|
83 |
// Test fallback from toNumber to toString for numeric conversion when toNumber doesn't exist |
1cd7d8af99ba
8072426: Can't compare Java objects to strings or numbers
attila
parents:
diff
changeset
|
84 |
(function() { |
1cd7d8af99ba
8072426: Can't compare Java objects to strings or numbers
attila
parents:
diff
changeset
|
85 |
var obj = makeJSObjectWithMembers({ |
1cd7d8af99ba
8072426: Can't compare Java objects to strings or numbers
attila
parents:
diff
changeset
|
86 |
valueOf: null, // Explicitly no valueOf |
1cd7d8af99ba
8072426: Can't compare Java objects to strings or numbers
attila
parents:
diff
changeset
|
87 |
toString: makeJSObjectConstantFunction("123") |
1cd7d8af99ba
8072426: Can't compare Java objects to strings or numbers
attila
parents:
diff
changeset
|
88 |
}); |
1cd7d8af99ba
8072426: Can't compare Java objects to strings or numbers
attila
parents:
diff
changeset
|
89 |
Assert["assertEquals(int,int)"](123, obj); |
1cd7d8af99ba
8072426: Can't compare Java objects to strings or numbers
attila
parents:
diff
changeset
|
90 |
})(); |
1cd7d8af99ba
8072426: Can't compare Java objects to strings or numbers
attila
parents:
diff
changeset
|
91 |
|
1cd7d8af99ba
8072426: Can't compare Java objects to strings or numbers
attila
parents:
diff
changeset
|
92 |
// Test fallback from toNumber to toString for numeric conversion when toNumber isn't a callable |
1cd7d8af99ba
8072426: Can't compare Java objects to strings or numbers
attila
parents:
diff
changeset
|
93 |
(function() { |
1cd7d8af99ba
8072426: Can't compare Java objects to strings or numbers
attila
parents:
diff
changeset
|
94 |
var obj = makeJSObjectWithMembers({ |
1cd7d8af99ba
8072426: Can't compare Java objects to strings or numbers
attila
parents:
diff
changeset
|
95 |
valueOf: new JSObject(addIsFunction(false, {})), |
1cd7d8af99ba
8072426: Can't compare Java objects to strings or numbers
attila
parents:
diff
changeset
|
96 |
toString: makeJSObjectConstantFunction("124") |
1cd7d8af99ba
8072426: Can't compare Java objects to strings or numbers
attila
parents:
diff
changeset
|
97 |
}); |
1cd7d8af99ba
8072426: Can't compare Java objects to strings or numbers
attila
parents:
diff
changeset
|
98 |
Assert["assertEquals(int,int)"](124, obj); |
1cd7d8af99ba
8072426: Can't compare Java objects to strings or numbers
attila
parents:
diff
changeset
|
99 |
})(); |
1cd7d8af99ba
8072426: Can't compare Java objects to strings or numbers
attila
parents:
diff
changeset
|
100 |
|
1cd7d8af99ba
8072426: Can't compare Java objects to strings or numbers
attila
parents:
diff
changeset
|
101 |
// Test fallback from toNumber to toString for numeric conversion when toNumber returns a non-primitive |
1cd7d8af99ba
8072426: Can't compare Java objects to strings or numbers
attila
parents:
diff
changeset
|
102 |
(function() { |
1cd7d8af99ba
8072426: Can't compare Java objects to strings or numbers
attila
parents:
diff
changeset
|
103 |
var obj = makeJSObjectWithMembers({ |
1cd7d8af99ba
8072426: Can't compare Java objects to strings or numbers
attila
parents:
diff
changeset
|
104 |
valueOf: makeJSObjectConstantFunction({}), |
1cd7d8af99ba
8072426: Can't compare Java objects to strings or numbers
attila
parents:
diff
changeset
|
105 |
toString: makeJSObjectConstantFunction("125") |
1cd7d8af99ba
8072426: Can't compare Java objects to strings or numbers
attila
parents:
diff
changeset
|
106 |
}); |
1cd7d8af99ba
8072426: Can't compare Java objects to strings or numbers
attila
parents:
diff
changeset
|
107 |
Assert["assertEquals(int,int)"](125, obj); |
1cd7d8af99ba
8072426: Can't compare Java objects to strings or numbers
attila
parents:
diff
changeset
|
108 |
})(); |
1cd7d8af99ba
8072426: Can't compare Java objects to strings or numbers
attila
parents:
diff
changeset
|
109 |
|
1cd7d8af99ba
8072426: Can't compare Java objects to strings or numbers
attila
parents:
diff
changeset
|
110 |
// Test TypeError from toNumber to toString when both return a non-primitive |
1cd7d8af99ba
8072426: Can't compare Java objects to strings or numbers
attila
parents:
diff
changeset
|
111 |
(function() { |
1cd7d8af99ba
8072426: Can't compare Java objects to strings or numbers
attila
parents:
diff
changeset
|
112 |
var obj = makeJSObjectWithMembers({ |
1cd7d8af99ba
8072426: Can't compare Java objects to strings or numbers
attila
parents:
diff
changeset
|
113 |
valueOf: makeJSObjectConstantFunction({}), |
1cd7d8af99ba
8072426: Can't compare Java objects to strings or numbers
attila
parents:
diff
changeset
|
114 |
toString: makeJSObjectConstantFunction({}) |
1cd7d8af99ba
8072426: Can't compare Java objects to strings or numbers
attila
parents:
diff
changeset
|
115 |
}); |
1cd7d8af99ba
8072426: Can't compare Java objects to strings or numbers
attila
parents:
diff
changeset
|
116 |
try { |
1cd7d8af99ba
8072426: Can't compare Java objects to strings or numbers
attila
parents:
diff
changeset
|
117 |
Number(obj); |
1cd7d8af99ba
8072426: Can't compare Java objects to strings or numbers
attila
parents:
diff
changeset
|
118 |
Assert.fail(); // must throw |
1cd7d8af99ba
8072426: Can't compare Java objects to strings or numbers
attila
parents:
diff
changeset
|
119 |
} catch(e) { |
1cd7d8af99ba
8072426: Can't compare Java objects to strings or numbers
attila
parents:
diff
changeset
|
120 |
Assert.assertTrue(e instanceof TypeError); |
1cd7d8af99ba
8072426: Can't compare Java objects to strings or numbers
attila
parents:
diff
changeset
|
121 |
} |
1cd7d8af99ba
8072426: Can't compare Java objects to strings or numbers
attila
parents:
diff
changeset
|
122 |
})(); |
1cd7d8af99ba
8072426: Can't compare Java objects to strings or numbers
attila
parents:
diff
changeset
|
123 |
|
1cd7d8af99ba
8072426: Can't compare Java objects to strings or numbers
attila
parents:
diff
changeset
|
124 |
// Test toString for string conversion |
1cd7d8af99ba
8072426: Can't compare Java objects to strings or numbers
attila
parents:
diff
changeset
|
125 |
(function() { |
1cd7d8af99ba
8072426: Can't compare Java objects to strings or numbers
attila
parents:
diff
changeset
|
126 |
var obj = makeJSObjectWithMembers({ |
1cd7d8af99ba
8072426: Can't compare Java objects to strings or numbers
attila
parents:
diff
changeset
|
127 |
toString: makeJSObjectConstantFunction("Hello") |
1cd7d8af99ba
8072426: Can't compare Java objects to strings or numbers
attila
parents:
diff
changeset
|
128 |
}); |
1cd7d8af99ba
8072426: Can't compare Java objects to strings or numbers
attila
parents:
diff
changeset
|
129 |
Assert.assertTrue("Hello" === String(obj)); |
1cd7d8af99ba
8072426: Can't compare Java objects to strings or numbers
attila
parents:
diff
changeset
|
130 |
Assert["assertEquals(String,String)"]("Hello", obj); |
1cd7d8af99ba
8072426: Can't compare Java objects to strings or numbers
attila
parents:
diff
changeset
|
131 |
})(); |
1cd7d8af99ba
8072426: Can't compare Java objects to strings or numbers
attila
parents:
diff
changeset
|
132 |
|
1cd7d8af99ba
8072426: Can't compare Java objects to strings or numbers
attila
parents:
diff
changeset
|
133 |
// Test fallback from toString to valueOf for string conversion when toString doesn't exist |
1cd7d8af99ba
8072426: Can't compare Java objects to strings or numbers
attila
parents:
diff
changeset
|
134 |
(function() { |
1cd7d8af99ba
8072426: Can't compare Java objects to strings or numbers
attila
parents:
diff
changeset
|
135 |
var obj = makeJSObjectWithMembers({ |
1cd7d8af99ba
8072426: Can't compare Java objects to strings or numbers
attila
parents:
diff
changeset
|
136 |
toString: null, |
1cd7d8af99ba
8072426: Can't compare Java objects to strings or numbers
attila
parents:
diff
changeset
|
137 |
valueOf: makeJSObjectConstantFunction("Hello1") |
1cd7d8af99ba
8072426: Can't compare Java objects to strings or numbers
attila
parents:
diff
changeset
|
138 |
}); |
1cd7d8af99ba
8072426: Can't compare Java objects to strings or numbers
attila
parents:
diff
changeset
|
139 |
Assert.assertTrue("Hello1" === String(obj)); |
1cd7d8af99ba
8072426: Can't compare Java objects to strings or numbers
attila
parents:
diff
changeset
|
140 |
Assert["assertEquals(String,String)"]("Hello1", obj); |
1cd7d8af99ba
8072426: Can't compare Java objects to strings or numbers
attila
parents:
diff
changeset
|
141 |
})(); |
1cd7d8af99ba
8072426: Can't compare Java objects to strings or numbers
attila
parents:
diff
changeset
|
142 |
|
1cd7d8af99ba
8072426: Can't compare Java objects to strings or numbers
attila
parents:
diff
changeset
|
143 |
// Test fallback from toString to valueOf for string conversion when toString is not callable |
1cd7d8af99ba
8072426: Can't compare Java objects to strings or numbers
attila
parents:
diff
changeset
|
144 |
(function() { |
1cd7d8af99ba
8072426: Can't compare Java objects to strings or numbers
attila
parents:
diff
changeset
|
145 |
var obj = makeJSObjectWithMembers({ |
1cd7d8af99ba
8072426: Can't compare Java objects to strings or numbers
attila
parents:
diff
changeset
|
146 |
toString: new JSObject(addIsFunction(false, {})), |
1cd7d8af99ba
8072426: Can't compare Java objects to strings or numbers
attila
parents:
diff
changeset
|
147 |
valueOf: makeJSObjectConstantFunction("Hello2") |
1cd7d8af99ba
8072426: Can't compare Java objects to strings or numbers
attila
parents:
diff
changeset
|
148 |
}); |
1cd7d8af99ba
8072426: Can't compare Java objects to strings or numbers
attila
parents:
diff
changeset
|
149 |
Assert["assertEquals(String,String)"]("Hello2", obj); |
1cd7d8af99ba
8072426: Can't compare Java objects to strings or numbers
attila
parents:
diff
changeset
|
150 |
})(); |
1cd7d8af99ba
8072426: Can't compare Java objects to strings or numbers
attila
parents:
diff
changeset
|
151 |
|
1cd7d8af99ba
8072426: Can't compare Java objects to strings or numbers
attila
parents:
diff
changeset
|
152 |
// Test fallback from toString to valueOf for string conversion when toString returns non-primitive |
1cd7d8af99ba
8072426: Can't compare Java objects to strings or numbers
attila
parents:
diff
changeset
|
153 |
(function() { |
1cd7d8af99ba
8072426: Can't compare Java objects to strings or numbers
attila
parents:
diff
changeset
|
154 |
var obj = makeJSObjectWithMembers({ |
1cd7d8af99ba
8072426: Can't compare Java objects to strings or numbers
attila
parents:
diff
changeset
|
155 |
toString: makeJSObjectConstantFunction({}), |
1cd7d8af99ba
8072426: Can't compare Java objects to strings or numbers
attila
parents:
diff
changeset
|
156 |
valueOf: makeJSObjectConstantFunction("Hello3") |
1cd7d8af99ba
8072426: Can't compare Java objects to strings or numbers
attila
parents:
diff
changeset
|
157 |
}); |
1cd7d8af99ba
8072426: Can't compare Java objects to strings or numbers
attila
parents:
diff
changeset
|
158 |
Assert["assertEquals(String,String)"]("Hello3", obj); |
1cd7d8af99ba
8072426: Can't compare Java objects to strings or numbers
attila
parents:
diff
changeset
|
159 |
})(); |
1cd7d8af99ba
8072426: Can't compare Java objects to strings or numbers
attila
parents:
diff
changeset
|
160 |
|
1cd7d8af99ba
8072426: Can't compare Java objects to strings or numbers
attila
parents:
diff
changeset
|
161 |
// Test toBoolean for JSObject |
1cd7d8af99ba
8072426: Can't compare Java objects to strings or numbers
attila
parents:
diff
changeset
|
162 |
(function() { |
1cd7d8af99ba
8072426: Can't compare Java objects to strings or numbers
attila
parents:
diff
changeset
|
163 |
Assert["assertEquals(boolean,boolean)"](true, new JSObject({})); |
1cd7d8af99ba
8072426: Can't compare Java objects to strings or numbers
attila
parents:
diff
changeset
|
164 |
})(); |