diff options
author | David Heinemeier Hansson <david@loudthinking.com> | 2006-03-03 19:34:23 +0000 |
---|---|---|
committer | David Heinemeier Hansson <david@loudthinking.com> | 2006-03-03 19:34:23 +0000 |
commit | 2e67f1adc8e52121270d1139665a965e3f0792d8 (patch) | |
tree | ccaf6b866c3895fede3fd00bf849a1f542394cf9 /activesupport/test | |
parent | 116658e69b9c4a722e6ae8717629b8cd0057db89 (diff) | |
download | rails-2e67f1adc8e52121270d1139665a965e3f0792d8.tar.gz rails-2e67f1adc8e52121270d1139665a965e3f0792d8.tar.bz2 rails-2e67f1adc8e52121270d1139665a965e3f0792d8.zip |
RJS now does enumerations, baby! (closes #3876) [Rick Olson]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3754 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activesupport/test')
-rw-r--r-- | activesupport/test/json.rb | 34 |
1 files changed, 19 insertions, 15 deletions
diff --git a/activesupport/test/json.rb b/activesupport/test/json.rb index c5b597abd7..fc4d7705b1 100644 --- a/activesupport/test/json.rb +++ b/activesupport/test/json.rb @@ -9,26 +9,30 @@ class Foo end class TestJSONEmitters < Test::Unit::TestCase - TrueTests = [[ true, %(true) ]] - FalseTests = [[ false, %(false) ]] - NilTests = [[ nil, %(null) ]] - NumericTests = [[ 1, %(1) ], - [ 2.5, %(2.5) ]] + TrueTests = [[ true, %(true) ]] + FalseTests = [[ false, %(false) ]] + NilTests = [[ nil, %(null) ]] + NumericTests = [[ 1, %(1) ], + [ 2.5, %(2.5) ]] - StringTests = [[ 'this is the string', %("this is the string") ], - [ 'a "string" with quotes', %("a \\"string\\" with quotes") ]] + StringTests = [[ 'this is the string', %("this is the string") ], + [ 'a "string" with quotes', %("a \\"string\\" with quotes") ]] - ArrayTests = [[ ['a', 'b', 'c'], %([\"a\", \"b\", \"c\"]) ], - [ [1, 'a', :b, nil, false], %([1, \"a\", \"b\", null, false]) ]] + ArrayTests = [[ ['a', 'b', 'c'], %([\"a\", \"b\", \"c\"]) ], + [ [1, 'a', :b, nil, false], %([1, \"a\", \"b\", null, false]) ]] - HashTests = [[ {:a => :b, :c => :d}, %({\"c\": \"d\", \"a\": \"b\"}) ]] + HashTests = [[ {:a => :b, :c => :d}, %({\"c\": \"d\", \"a\": \"b\"}) ]] - SymbolTests = [[ :a, %("a") ], - [ :this, %("this") ], - [ :"a b", %("a b") ]] + SymbolTests = [[ :a, %("a") ], + [ :this, %("this") ], + [ :"a b", %("a b") ]] + + ObjectTests = [[ Foo.new(1, 2), %({\"a\": 1, \"b\": 2}) ]] + + VariableTests = [[ ActiveSupport::JSON::Variable.new('foo'), 'foo'], + [ ActiveSupport::JSON::Variable.new('alert("foo")'), 'alert("foo")']] + RegexpTests = [[ /^a/, '/^a/' ], /^\w{1,2}[a-z]+/ix, '/^\\w{1,2}[a-z]+/ix'] - ObjectTests = [[ Foo.new(1, 2), %({\"a\": 1, \"b\": 2}) ]] - constants.grep(/Tests$/).each do |class_tests| define_method("test_#{class_tests[0..-6].downcase}") do self.class.const_get(class_tests).each do |pair| |