Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Changeset 7747

Show
Ignore:
Timestamp:
10/05/07 10:07:23 (1 year ago)
Author:
nzkoz
Message:

Ensure json tests run in stable.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/1-2-stable/activesupport/lib/active_support/json/encoders/core.rb

    r5498 r7747  
    2424        "\r" =>    '\r', 
    2525        "\t" =>    '\t', 
    26         '"' =>     '\"', 
    27         '\\' =>    '\\\\' 
     26        '"'  =>    '\"', 
     27        '\\' =>    '\\\\', 
     28        '<'  =>    '\\074', 
     29        '>'  =>    '\\076' 
    2830      } 
    2931       
    3032      define_encoder String do |string| 
    31         '"' + string.gsub(/[\010\f\n\r\t"\\]/) { |s| 
     33        '"' + string.gsub(/[\010\f\n\r\t"\\<>]/) { |s| 
    3234          ESCAPED_CHARS[s] 
    3335        }.gsub(/([\xC0-\xDF][\x80-\xBF]| 
  • branches/1-2-stable/activesupport/test/json_test.rb

    r5498 r7747  
    11require File.dirname(__FILE__) + '/abstract_unit' 
    22 
    3 class Foo 
     3class JsonFoo 
    44  def initialize(a, b) 
    55    @a, @b = a, b 
     
    1515 
    1616  StringTests   = [[ 'this is the string',     %("this is the string")         ], 
    17                    [ 'a "string" with quotes', %("a \\"string\\" with quotes") ]] 
     17                   [ 'a "string" with quotes<script>', %("a \\"string\\" with quotes\\074script\\076") ]] 
    1818 
    1919  ArrayTests    = [[ ['a', 'b', 'c'],          %([\"a\", \"b\", \"c\"])          ], 
     
    2424                   [ :"a b", %("a b")  ]] 
    2525 
    26   ObjectTests   = [[ Foo.new(1, 2), %({\"a\": 1, \"b\": 2}) ]] 
     26  ObjectTests   = [[ JsonFoo.new(1, 2), %({\"a\": 1, \"b\": 2}) ]] 
    2727 
    2828  VariableTests = [[ ActiveSupport::JSON::Variable.new('foo'), 'foo'], 
     
    7272  def test_unquote_hash_key_identifiers 
    7373    values = {0 => 0, 1 => 1, :_ => :_, "$" => "$", "a" => "a", :A => :A, :A0 => :A0, "A0B" => "A0B"}     
    74     assert_equal %({"a": "a", 0: 0, "_": "_", 1: 1, "$": "$", "A": "A", "A0B": "A0B", "A0": "A0"}), values.to_json 
    75     unquote(true) { assert_equal %({a: "a", 0: 0, _: "_", 1: 1, $: "$", A: "A", A0B: "A0B", A0: "A0"}), values.to_json } 
     74     
     75    assert_equal %({"a": "a"}), {"a"=>"a"}.to_json 
     76    assert_equal %({0: 0}),   { 0 => 0 }.to_json 
     77    assert_equal %({"_": "_"}), {:_ =>:_ }.to_json 
     78    assert_equal %({"$": "$"}), {"$"=>"$"}.to_json 
     79     
     80    unquote(true) do 
     81      assert_equal %({a: "a"}), {"a"=>"a"}.to_json 
     82      assert_equal %({0: 0}),   { 0 => 0 }.to_json 
     83      assert_equal %({_: "_"}), {:_ =>:_ }.to_json 
     84      assert_equal %({$: "$"}), {"$"=>"$"}.to_json 
     85    end 
    7686  end 
    7787