Sha256: a45dfaa524297420182d10cc0dbe81ad334313c71c1a6a1d47ed665b90015cb9

Contents?: true

Size: 702 Bytes

Versions: 17

Compression:

Stored size: 702 Bytes

Contents

require File.expand_path(File.join(File.dirname(__FILE__), "/../../helper"))

class TernaryNodeTest < Johnson::NodeTestCase
  def test_ternary
    assert_sexp([
      [:var, [[:assign,
        [:name, "x"],
        [:ternary,
          [:lt, [:name, "y"], [:lit, 10]],
          [:lit, 20],
          [:lit, 30]
        ]
      ]]]],
                @parser.parse('var x = y < 10 ? 20 : 30')
               )
    assert_ecma('var x = y < 10 ? 20 : 30;',
                @parser.parse('var x = y < 10 ? 20 : 30')
               )
  end

  def test_weird_rounding
    ecma = @parser.parse('(value < 0.00001) ? 0 : value;').to_ecma
    assert_match(/\(value < 1.0e-[0]*5\) \? 0 : value;/, ecma)
  end
end

Version data entries

17 entries across 17 versions & 2 rubygems

Version Path
jbarnette-johnson-1.0.0.200806240111 test/johnson/nodes/ternary_test.rb
jbarnette-johnson-1.0.0.200807291507 test/johnson/nodes/ternary_test.rb
jbarnette-johnson-1.0.0.200808062051 test/johnson/nodes/ternary_test.rb
jbarnette-johnson-1.0.0.200808062111 test/johnson/nodes/ternary_test.rb
jbarnette-johnson-1.0.0.200811251942 test/johnson/nodes/ternary_test.rb
jbarnette-johnson-1.0.0.20081126120511 test/johnson/nodes/ternary_test.rb
jbarnette-johnson-1.0.0.20090127202936 test/johnson/nodes/ternary_test.rb
jbarnette-johnson-1.0.0.20090225110820 test/johnson/nodes/ternary_test.rb
jbarnette-johnson-1.0.0.20090326122910 test/johnson/nodes/ternary_test.rb
jbarnette-johnson-1.0.0.20090326154650 test/johnson/nodes/ternary_test.rb
jbarnette-johnson-1.0.0.20090326161333 test/johnson/nodes/ternary_test.rb
jbarnette-johnson-1.0.0.20090402144841 test/johnson/nodes/ternary_test.rb
jbarnette-johnson-1.0.0.20090402155420 test/johnson/nodes/ternary_test.rb
johnson-1.2.0 test/johnson/nodes/ternary_test.rb
johnson-1.1.1 test/johnson/nodes/ternary_test.rb
johnson-1.1.2 test/johnson/nodes/ternary_test.rb
johnson-1.1.0 test/johnson/nodes/ternary_test.rb