Sha256: 2b2830d40f7bc89d78a556dcc52a02d73639b9ba57f03359a9efa9c4b555cfbb

Contents?: true

Size: 1.63 KB

Versions: 9

Compression:

Stored size: 1.63 KB

Contents

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

module Johnson
  class PreludeTest < Johnson::TestCase
    def test_symbols_are_interned
      assert(@runtime.evaluate("Johnson.symbolize('foo') === Johnson.symbolize('foo')"))
    end
    
    def test_strings_had_a_to_symbol_method
      assert_js_equal(:monkeys, "'monkeys'.toSymbol()")
    end
    
    def test_string_to_symbol_is_not_enumerable
      assert(!@runtime.evaluate(<<-END))
        var flag = false;
        for (x in "foo") { if (x == 'toSymbol') flag = true }
        flag
      END
    end
    
    def test_symbol_to_string
      assert_equal("monkey", @runtime.evaluate("Johnson.symbolize('monkey').toString()"))
    end

    def test_symbol_inspect
      assert_equal(":monkey", @runtime.evaluate("Johnson.symbolize('monkey').inspect()"))
    end
    
    def test_all_of_ruby_is_available
      assert_raise(Johnson::Error) { @runtime.evaluate("Ruby.Set.new()") }
      
      @runtime.evaluate("Ruby.require('set')")
      assert_kind_of(Set, @runtime.evaluate("Ruby.Set.new()"))
    end
    
    def test_require_an_existing_js_file_without_extension
      assert_js("Johnson.require('johnson/template')")
    end
    
    def test_require_returns_false_the_second_time_around
      assert_js("Johnson.require('johnson/template')")
      assert(!@runtime.evaluate("Johnson.require('johnson/template')"))
    end
    
    def test_missing_requires_throw_LoadError
      assert_js(<<-END)
        var flag = false;
        
        try { Johnson.require("johnson/__nonexistent"); }
        catch(ex) { flag = true; }
        
        flag;
      END
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
jbarnette-johnson-1.0.0.200806240111 test/johnson/prelude_test.rb
jbarnette-johnson-1.0.0.200807291507 test/johnson/prelude_test.rb
jbarnette-johnson-1.0.0.200808062051 test/johnson/prelude_test.rb
jbarnette-johnson-1.0.0.200808062111 test/johnson/prelude_test.rb
jbarnette-johnson-1.0.0.200811251942 test/johnson/prelude_test.rb
jbarnette-johnson-1.0.0.20081126120511 test/johnson/prelude_test.rb
jbarnette-johnson-1.0.0.20090127202936 test/johnson/prelude_test.rb
jbarnette-johnson-1.0.0.20090225110820 test/johnson/prelude_test.rb
jbarnette-johnson-1.0.0.20090326122910 test/johnson/prelude_test.rb