| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
package org.mozilla.javascript.tests; |
| 9 |
|
| 10 |
import junit.framework.TestCase; |
| 11 |
|
| 12 |
import org.mozilla.javascript.Context; |
| 13 |
import org.mozilla.javascript.ContextAction; |
| 14 |
import org.mozilla.javascript.Scriptable; |
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
public class NativeStringTest extends TestCase { |
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
public void testtoLowerCaseApply() { |
| 28 |
assertEvaluates("hello", "var x = String.toLowerCase; x.apply('HELLO')"); |
| 29 |
assertEvaluates("hello", "String.toLowerCase('HELLO')"); |
| 30 |
} |
| 31 |
|
| 32 |
private void assertEvaluates(final Object expected, final String source) { |
| 33 |
final ContextAction action = new ContextAction() { |
| 34 |
public Object run(Context cx) { |
| 35 |
final Scriptable scope = cx.initStandardObjects(); |
| 36 |
final Object rep = cx.evaluateString(scope, source, "test.js", |
| 37 |
0, null); |
| 38 |
assertEquals(expected, rep); |
| 39 |
return null; |
| 40 |
} |
| 41 |
}; |
| 42 |
Utils.runWithAllOptimizationLevels(action); |
| 43 |
} |
| 44 |
} |