Changeset 4795
- Timestamp:
- 08/20/06 17:27:28 (2 years ago)
- Files:
-
- trunk/activesupport/test/json.rb (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/activesupport/test/json.rb
r4595 r4795 20 20 [ [1, 'a', :b, nil, false], %([1, \"a\", \"b\", null, false]) ]] 21 21 22 HashTests = [[ {:a => :b, :c => :d}, %({\"c\": \"d\", \"a\": \"b\"}) ]]23 24 22 SymbolTests = [[ :a, %("a") ], 25 23 [ :this, %("this") ], … … 30 28 VariableTests = [[ ActiveSupport::JSON::Variable.new('foo'), 'foo'], 31 29 [ ActiveSupport::JSON::Variable.new('alert("foo")'), 'alert("foo")']] 32 RegexpTests = [[ /^a/, '/^a/' ], /^\w{1,2}[a-z]+/ix, '/^\\w{1,2}[a-z]+/ix']30 RegexpTests = [[ /^a/, '/^a/' ], [/^\w{1,2}[a-z]+/ix, '/^\\w{1,2}[a-z]+/ix']] 33 31 34 32 constants.grep(/Tests$/).each do |class_tests| … … 38 36 end 39 37 end 38 end 39 40 def test_hash_encoding 41 assert_equal %({\"a\": \"b\"}), { :a => :b }.to_json 42 assert_equal %({\"a\": 1}), { 'a' => 1 }.to_json 43 assert_equal %({\"a\": [1, 2]}), { 'a' => [1,2] }.to_json 44 45 sorted_json = 46 '{' + {:a => :b, :c => :d}.to_json[1..-2].split(', ').sort.join(', ') + '}' 47 assert_equal %({\"a\": \"b\", \"c\": \"d\"}), sorted_json 40 48 end 41 49