Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 63 lines (50 sloc) 1.442 kb
d50ae782 » jbarnette
2008-03-12 Skeletal delegating Johnson::Context.
1 require "rubygems"
2 require "test/unit"
3
053d7333 » jbarnette
2008-03-12 More deps improvements, skeletal extension bits, etc.
4 require "johnson"
85757c70 » jbarnette
2008-03-12 Conversions for nil, booleans, and strings.
5
6 module Johnson
27a046fd » flavorjones
2009-06-06 added option to stress garbage-collection during tests by setting JOH…
7 module GCTearDown
8 def teardown
9 if ENV['JOHNSON_GC']
10 STDOUT.putc '!'
11 GC.start
12 end
13 end
14 end
15
85757c70 » jbarnette
2008-03-12 Conversions for nil, booleans, and strings.
16 class TestCase < Test::Unit::TestCase
27a046fd » flavorjones
2009-06-06 added option to stress garbage-collection during tests by setting JOH…
17 include GCTearDown
18
54ae9456 » tenderlove
2008-05-23 fixing warnings, converting objects to ruby, passing OK flag and addi…
19 class TestLogger
20 def debug(string)
21 puts string
22 end
23 end
24
bd5ec3e8 » jbarnette
2008-09-23 Minor tweaks to the test helper for miniunit.
25 undef :default_test if method_defined? :default_test
9a1447e9 » tenderlove
2008-06-10 drying up tests
26
27 def setup
28 @runtime = Johnson::Runtime.new
47b681e4 » tenderlove
2008-06-10 rooting the debugger
29 #@runtime.delegate.gc_zeal = 2
30 #@runtime.delegate.debugger = Johnson::SpiderMonkey::Debugger.new(TestLogger.new)
9a1447e9 » tenderlove
2008-06-10 drying up tests
31 end
85757c70 » jbarnette
2008-03-12 Conversions for nil, booleans, and strings.
32
33 def assert_js(expression, options={})
ae3584f2 » jbarnette
2008-05-30 Runtime is the new Context. One context per Ruby thread.
34 runtime = options[:runtime] || @runtime
35 assert(runtime.evaluate(expression), "Expected JS expression [#{expression}] to be true.")
1d6a6e11 » jbarnette
2008-03-13 Support for marshaling numbers.
36 end
37
38 def assert_js_equal(expected, expression, options={})
ae3584f2 » jbarnette
2008-05-30 Runtime is the new Context. One context per Ruby thread.
39 runtime = options.delete(:runtime) || @runtime
40 options.each { |k, v| runtime[k.to_s] = v }
41 assert_equal(expected, runtime.evaluate(expression))
85757c70 » jbarnette
2008-03-12 Conversions for nil, booleans, and strings.
42 end
43 end
cb8d054d » aaronp
2008-03-20 adding node tests
44
45 class NodeTestCase < Test::Unit::TestCase
27a046fd » flavorjones
2009-06-06 added option to stress garbage-collection during tests by setting JOH…
46 include GCTearDown
cb8d054d » aaronp
2008-03-20 adding node tests
47 include Johnson::Nodes
48
bd5ec3e8 » jbarnette
2008-09-23 Minor tweaks to the test helper for miniunit.
49 undef :default_test if method_defined? :default_test
69ace872 » jbarnette
2008-03-31 JS-land proxies for Ruby objects. No support for GC or roundtripping.
50
cb8d054d » aaronp
2008-03-20 adding node tests
51 def setup
52 @parser = Johnson::Parser
53 end
54
55 def assert_sexp(expected, actual)
56 assert_equal(expected, actual.to_sexp)
57 end
597bdcfc » aaronp
2008-03-31 adding ecma visitr
58
59 def assert_ecma(expected, actual)
60 assert_equal(expected, actual.to_ecma)
61 end
cb8d054d » aaronp
2008-03-20 adding node tests
62 end
85757c70 » jbarnette
2008-03-12 Conversions for nil, booleans, and strings.
63 end
Something went wrong with that request. Please try again.