/**
 * 
 */
package org.mozilla.javascript.tests;

import junit.framework.TestCase;

import org.mozilla.javascript.Context;
import org.mozilla.javascript.ContextAction;
import org.mozilla.javascript.Scriptable;

/**
 * @author Marc Guillemot
 */
public class NativeStringTest extends TestCase {
    
	/**
	 * Test for bug #492359
	 * https://bugzilla.mozilla.org/show_bug.cgi?id=492359
	 * Calling generic String or Array functions without arguments was causing ArrayIndexOutOfBoundsException
	 * in 1.7R2
	 */
    public void testtoLowerCaseApply() {
        final String source = "var x = String.toLowerCase; x.apply('HELLO')";
        final ContextAction action = new ContextAction() {
        	public Object run(Context cx) {
        		final Scriptable scope = cx.initStandardObjects();
       			final Object rep = cx.evaluateString(scope, source, "test.js", 0, null);
       			assertEquals("hello", rep);
       			return null;
        	}
        };
        Utils.runWithAllOptimizationLevels(action);
    }
 }

@@ -557,29 +557,32 @@
     
-final String source =
+assertEvaluates(%22hello%22,
  %22va
@@ -624,18 +624,223 @@
 HELLO')%22
+)
 ;%0A
+        assertEvaluates(%22hello%22, %22String.toLowerCase('HELLO')%22); // first patch proposed to #492359 was breaking this%0A    %7D%0A%0A    private void assertEvaluates(final Object expected, final String source) %7B%0A
         
@@ -898,17 +898,20 @@
         
-%09
+    
 public O
@@ -942,18 +942,24 @@
         
-%09%09
+        
 final Sc
@@ -1008,19 +1008,25 @@
 %0A       
+      
-%09%09%09
+   
 final Ob
@@ -1079,16 +1079,40 @@
 est.js%22,
+%0A                       
  0, null
@@ -1121,19 +1121,25 @@
 %0A       
+ 
-%09%09%09
+        
 assertEq
@@ -1143,23 +1143,24 @@
 tEquals(
-%22hello%22
+expected
 , rep);%0A
@@ -1170,11 +1170,17 @@
     
-%09%09%09
+         
 retu
@@ -1196,17 +1196,20 @@
         
-%09
+    
 %7D%0A      

Update to unit test