@@ -32,19 +32,25 @@ def test_block_syntax
3232 end
3333 assert result == COMPILED_ADVANCED
3434 end
35-
35+
3636 def test_jar_and_java_specifiation
3737 jar = Dir [ 'vendor/closure-compiler-*.jar' ] . first
38- java = `which java` . strip
39- compiler = Compiler . new ( :java => java , :jar_file => jar )
40- assert compiler . compress ( ORIGINAL ) == COMPILED_SIMPLE
38+ unless java = ( `which java` rescue nil )
39+ java = `where java` rescue nil # works on newer windows
40+ end
41+ if java
42+ compiler = Compiler . new ( :java => java . strip , :jar_file => jar )
43+ assert compiler . compress ( ORIGINAL ) == COMPILED_SIMPLE
44+ else
45+ puts "could not `which/where java` skipping test"
46+ end
4147 end
4248
4349 def test_exceptions
44- assert_raises ( Closure ::Error ) do
50+ assert_raise ( Closure ::Error ) do
4551 Compiler . new . compile ( '1++' )
4652 end
47- assert_raises ( Closure ::Error ) do
53+ assert_raise ( Closure ::Error ) do
4854 Compiler . new . compile ( 'obj = [1 2, 3]' )
4955 end
5056 end
@@ -59,7 +65,12 @@ def test_permissions
5965 end
6066
6167 def test_serialize_options
62- assert_equal [ "--externs" , "library1.js" , "--compilation_level" , "ADVANCED_OPTIMIZATIONS" ] , Closure ::Compiler . new . send ( :serialize_options , 'externs' => 'library1.js' , "compilation_level" => "ADVANCED_OPTIMIZATIONS" )
68+ options = { 'externs' => 'library1.js' , "compilation_level" => "ADVANCED_OPTIMIZATIONS" }
69+ # ["--externs", "library1.js", "--compilation_level", "ADVANCED_OPTIMIZATIONS"]
70+ # although Hash in 1.8 might change the order to :
71+ # ["--compilation_level", "ADVANCED_OPTIMIZATIONS", "--externs", "library1.js"]
72+ expected_options = options . to_a . map { |arr | [ "--#{ arr [ 0 ] } " , arr [ 1 ] ] } . flatten
73+ assert_equal expected_options , Closure ::Compiler . new . send ( :serialize_options , options )
6374 end
6475
6576 def test_serialize_options_for_arrays
0 commit comments