Sha256: 35a870781ed36f28e9c271334ab6547d4d235a5239912e8f3c804ca291f3dea5

Contents?: true

Size: 866 Bytes

Versions: 10

Compression:

Stored size: 866 Bytes

Contents

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

module Johnson
  module Conversions
    class CallableTest < Johnson::TestCase
      def test_proc_works_in_jsland
        @runtime[:squared] = Proc.new { |x| x * x }
        assert_js_equal(4, "squared(2)")
      end
      
      def test_procs_roundtrip
        @runtime[:k] = k = lambda { |x| x }
        assert_same(k, @runtime.evaluate("k"))
      end
      
      def test_proc_js_function_proxy_gets_reused
        @runtime[:k] = k = lambda { |x| x }
        @runtime[:kk] = k
        assert_js("k === kk")
      end
      
      class CallableThing
        def call
          "foo"
        end
      end
      
      def test_anything_with_a_call_method_can_be_called_as_a_method
        @runtime[:c] = CallableThing.new
        assert_js_equal("foo", "c()")
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 4 rubygems

Version Path
johnson19-2.0.0.pre3 test/johnson/generic/conversions/callable_test.rb
pre-johnson-2.0.0 test/johnson/generic/conversions/callable_test.rb
johnson-2.0.0.pre3 test/johnson/generic/conversions/callable_test.rb
johnson-2.0.0.pre2 test/johnson/generic/conversions/callable_test.rb
johnson-2.0.0.pre1 test/johnson/generic/conversions/callable_test.rb
johnson-2.0.0.pre0 test/johnson/generic/conversions/callable_test.rb
smparkes-johnson-1.1.2.6 test/johnson/generic/conversions/callable_test.rb
smparkes-johnson-1.1.2.5 test/johnson/generic/conversions/callable_test.rb
smparkes-johnson-1.1.2.4 test/johnson/generic/conversions/callable_test.rb
smparkes-johnson-1.1.2.3 test/johnson/generic/conversions/callable_test.rb