| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
package org.mozilla.javascript.tests.es5; |
| 9 |
|
| 10 |
import org.junit.After; |
| 11 |
import org.junit.Before; |
| 12 |
import org.mozilla.javascript.*; |
| 13 |
|
| 14 |
import static org.mozilla.javascript.tests.Evaluator.eval; |
| 15 |
import static org.junit.Assert.assertEquals; |
| 16 |
|
| 17 |
import org.junit.Test; |
| 18 |
|
| 19 |
public class ObjectToStringNullUndefinedTest { |
| 20 |
private Context cx; |
| 21 |
private ScriptableObject scope; |
| 22 |
|
| 23 |
@Before |
| 24 |
public void setUp() { |
| 25 |
cx = Context.enter(); |
| 26 |
cx.setLanguageVersion(200); |
| 27 |
scope = cx.initStandardObjects(); |
| 28 |
} |
| 29 |
|
| 30 |
@After |
| 31 |
public void tearDown() { |
| 32 |
Context.exit(); |
| 33 |
} |
| 34 |
|
| 35 |
@Test |
| 36 |
public void testToStringNullUndefined() { |
| 37 |
Object result0 = cx.evaluateString( |
| 38 |
scope, "Object.prototype.toString.call(null)", |
| 39 |
"15.2.4.2", 1, null |
| 40 |
); |
| 41 |
assertEquals("[object Null]", result0); |
| 42 |
|
| 43 |
Object result1 = cx.evaluateString( |
| 44 |
scope, "Object.prototype.toString.call(undefined)", |
| 45 |
"15.2.4.2", 1, null |
| 46 |
); |
| 47 |
assertEquals("[object Undefined]", result1); |
| 48 |
} |
| 49 |
} |