8145305: fix Nashorn shebang handling on Cygwin
authormhaupt
Mon, 18 Jan 2016 11:31:43 +0100
changeset 35323 0ef5f8b7cd23
parent 35322 eff26d265a9d
child 35324 b9b0e5fdc996
8145305: fix Nashorn shebang handling on Cygwin Reviewed-by: hannesw, sundar
nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/resources/Functions.properties
nashorn/test/script/nosecurity/JDK-8144221.js
--- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/resources/Functions.properties	Mon Jan 18 10:25:36 2016 +0100
+++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/resources/Functions.properties	Mon Jan 18 11:31:43 2016 +0100
@@ -42,6 +42,54 @@
 
 Object.bindProperties=binds the source object's properties to the target object (nashorn extension)
 
+Array.isArray=tells whether the argument is an array
+
+Array.prototype.toString=returns a string representation of this array
+
+Array.prototype.assertNumeric=asserts that the array is numeric, throws a type error if this is not the case
+
+Array.prototype.toLocaleString=returns a locale-specific string representation of this array
+
+Array=creates a new array
+
+Array.prototype.concat=concatenates arrays
+
+Array.prototype.join=returns a string representation of the array, with a separator placed between elements
+
+Array.prototype.pop=returns the element from the end of the array, or undefined
+
+Array.prototype.push=appends an element to the end of the array
+
+Array.prototype.reverse=reverses the array
+
+Array.prototype.shift=removes the first element from the array and returns that element
+
+Array.prototype.slice=returns a shallow copy of a slice of the array
+
+Array.prototype.sort=sorts the array
+
+Array.prototype.splice=changes the content of the array by removing and/or adding elements
+
+Array.prototype.unshift=adds one or more elements to the beginning of the array
+
+Array.prototype.indexOf=retrieves the first index of an element in the array, or -1 if the element is not found
+
+Array.prototype.lastIndexOf=retrieves the last index of an element in the array, or -1 if the element is not found
+
+Array.prototype.every=applies a predicate to all elements of the array, returns true if the predicate evaluates to true for all
+
+Array.prototype.some=tests whether a predicate evaluates to true for some element in the array
+
+Array.prototype.forEach=applies a function to all elements in the array
+
+Array.prototype.map=applies a function to all elements in the array, returns the array of results
+
+Array.prototype.filter=returns an array with those elements from this array that match a filter function
+
+Array.prototype.reduce=applies a left-fold to the array and returns the result
+
+Array.prototype.reduceRight=applies a right-fold to the array and returns the result
+
 Function=creates a new function with the given parameters and function body
 
 Function.prototype.toString=returns a string representation of this function
--- a/nashorn/test/script/nosecurity/JDK-8144221.js	Mon Jan 18 10:25:36 2016 +0100
+++ b/nashorn/test/script/nosecurity/JDK-8144221.js	Mon Jan 18 11:31:43 2016 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -25,7 +25,6 @@
  * Test that shebang handling works properly.
  *
  * @test
- * @runif os.not.windows
  * @option -scripting
  * @run
  */
@@ -126,8 +125,9 @@
 }
 
 function run(viajjs, name, arg1, arg2) {
-    var prefix = viajjs ? "${jjs} -scripting " : ''
-    $EXEC("${prefix}./shebang.js ${arg1} ${arg2}")
+    var prefix = viajjs ? "${jjs} -scripting " : win ? 'sh -c "' : '',
+        suffix = viajjs ? '' : win ? '"' : ''
+    $EXEC("${prefix}./shebang.js ${arg1} ${arg2}${suffix}")
     print("* ${name} via ${viajjs ? 'jjs' : 'shebang'}")
     print($OUT.trim())
     print($ERR.trim())
@@ -143,8 +143,8 @@
     $EXEC('chmod +x shebang.js')
     run(false, 'noargs', '', '')
     run(true, 'noargs', '', '')
-    run(false, 'withargs', 'a.js', '"hello world"')
-    run(true, 'withargs', 'a.js', '"hello world"')
+    run(false, 'withargs', 'a.js', "'hello world'")
+    run(true, 'withargs', 'a.js', "'hello world'")
     $EXEC('rm shebang.js')
 })