Project

General

Profile

datemutate.patch

tenderlovemaking (Aaron Patterson), 01/19/2012 04:21 AM

View differences:

ext/date/date_parse.c
2098 2098
    rb_match_busy(backref);
2099 2099

  
2100 2100
    hash = rb_hash_new();
2101
    str  = rb_str_dup(str);
2101 2102

  
2102 2103
    if (xmlschema_datetime(str, hash))
2103 2104
	goto ok;
......
2169 2170
    rb_match_busy(backref);
2170 2171

  
2171 2172
    hash = rb_hash_new();
2173
    str = rb_str_dup(str);
2172 2174
    rfc2822(str, hash);
2173 2175
    rb_backref_set(backref);
2174 2176
    return hash;
......
2315 2317
    rb_match_busy(backref);
2316 2318

  
2317 2319
    hash = rb_hash_new();
2320
    str = rb_str_dup(str);
2318 2321

  
2319 2322
    if (httpdate_type1(str, hash))
2320 2323
	goto ok;
test/date/test_date_parse.rb
1019 1019
    assert_equal(Date::ITALY + 10, d.start)
1020 1020
  end
1021 1021

  
1022
  def test_date_xmlschema_does_not_mutate
1023
    x = "2006-02-13T10:37:00.000-05:00"
1024
    y = x.dup
1025
    Date.xmlschema x
1026
    assert_equal y, x
1027
  end
1028

  
1029
  def test_datetime_xmlschema_does_not_mutate
1030
    x = "2006-02-13T10:37:00.000-05:00"
1031
    y = x.dup
1032
    DateTime.xmlschema x
1033
    assert_equal y, x
1034
  end
1035

  
1022 1036
  def test_rfc2822
1023 1037
    assert_instance_of(Date, Date.rfc2822)
1024 1038
    assert_instance_of(DateTime, DateTime.rfc2822)
......
1034 1048
    assert_equal(Date::ITALY + 10, d.start)
1035 1049
  end
1036 1050

  
1051
  def test_rfc2822_does_not_mutate
1052
    x = 'Mon, 1 Jan -4712 00:00:00 +0000'
1053
    y = x.dup
1054

  
1055
    Date.rfc2822 x
1056
    assert_equal y, x
1057

  
1058
    DateTime.rfc2822 x
1059
    assert_equal y, x
1060
  end
1061

  
1037 1062
  def test_httpdate
1038 1063
    assert_instance_of(Date, Date.httpdate)
1039 1064
    assert_instance_of(DateTime, DateTime.httpdate)
......
1047 1072
    assert_equal(Date::ITALY + 10, d.start)
1048 1073
  end
1049 1074

  
1075
  def test_httpdate_does_not_mutate
1076
    x = "Mon, 01 Jan -4712 00:00:00 GMT"
1077
    y = x.dup
1078

  
1079
    Date.httpdate x
1080
    assert_equal y, x
1081

  
1082
    DateTime.httpdate x
1083
    assert_equal y, x
1084
  end
1085

  
1050 1086
  def test_jisx0301
1051 1087
    assert_instance_of(Date, Date.jisx0301)
1052 1088
    assert_instance_of(DateTime, DateTime.jisx0301)