[macruby-changes] [1754] MacRuby/branches/experimental
source_changes at macosforge.org
source_changes at macosforge.org
Fri Jun 5 14:41:39 PDT 2009
Revision: 1754
http://trac.macosforge.org/projects/ruby/changeset/1754
Author: lsansonetti at apple.com
Date: 2009-06-05 14:41:38 -0700 (Fri, 05 Jun 2009)
Log Message:
-----------
String#dump: taint the resulted string if the receiver string is tainted, return subclasses if the receiver is a subclass of String, re-enabled dump spec and tagging one failing spec
Modified Paths:
--------------
MacRuby/branches/experimental/string.c
Added Paths:
-----------
MacRuby/branches/experimental/spec/frozen/core/string/dump_spec.rb
Removed Paths:
-------------
MacRuby/branches/experimental/spec/frozen/core/string/dump_spec_disabled.rb
Copied: MacRuby/branches/experimental/spec/frozen/core/string/dump_spec.rb (from rev 1748, MacRuby/branches/experimental/spec/frozen/core/string/dump_spec_disabled.rb)
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/string/dump_spec.rb (rev 0)
+++ MacRuby/branches/experimental/spec/frozen/core/string/dump_spec.rb 2009-06-05 21:41:38 UTC (rev 1754)
@@ -0,0 +1,46 @@
+# -*- encoding: utf-8 -*-
+require File.dirname(__FILE__) + '/../../spec_helper'
+require File.dirname(__FILE__) + '/fixtures/classes.rb'
+
+describe "String#dump" do
+ ruby_version_is ""..."1.9" do
+ # Older versions of MRI wrongly print \b as \010
+ it "returns a string with nonprinting charaters replaced by escaped-numeric notation" do
+ ("\000".."A").to_a.to_s.dump.should == "\"\\000\\001\\002\\003\\004\\005\\006\\a\\b\\t\\n\\v\\f\\r\\016\\017\\020\\021\\022\\023\\024\\025\\026\\027\\030\\031\\032\\e\\034\\035\\036\\037 !\\\"\\\#$%&'()*+,-./0123456789\""
+ end
+ end
+
+ # This test is different on 1.9 for two reasons: 1) 1.9 uses a different
+ # format of escaping, 2) 1.9 changes the output of Array#to_s.
+ ruby_version_is "1.9" do
+ it "returns a string with nonprinting charaters replaced by \\x notation" do
+ ("\000".."A").to_a.join('').should == "\x00\x01\x02\x03\x04\x05\x06\a\b\t\n\v\f\r\x0E\x0F\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1A\e\x1C\x1D\x1E\x1F !\"\#$%&'()*+,-./0123456789:;<=>?@A"
+ end
+ end
+
+ # $KCODE is deprecated on 1.9
+ ruby_version_is ""..."1.9" do
+ it "ignores the $KCODE setting" do
+ old_kcode = $KCODE
+
+ begin
+ $KCODE = "NONE"
+ "äöü".dump.should == "\"\\303\\244\\303\\266\\303\\274\""
+
+ $KCODE = "UTF-8"
+ "äöü".dump.should == "\"\\303\\244\\303\\266\\303\\274\""
+ ensure
+ $KCODE = old_kcode
+ end
+ end
+ end
+
+ it "taints result when self is tainted" do
+ "".taint.dump.tainted?.should == true
+ "x".taint.dump.tainted?.should == true
+ end
+
+ it "returns a subclass instance for subclasses" do
+ StringSpecs::MyString.new("hi!").dump.class.should == StringSpecs::MyString
+ end
+end
Deleted: MacRuby/branches/experimental/spec/frozen/core/string/dump_spec_disabled.rb
===================================================================
--- MacRuby/branches/experimental/spec/frozen/core/string/dump_spec_disabled.rb 2009-06-05 21:33:49 UTC (rev 1753)
+++ MacRuby/branches/experimental/spec/frozen/core/string/dump_spec_disabled.rb 2009-06-05 21:41:38 UTC (rev 1754)
@@ -1,46 +0,0 @@
-# -*- encoding: utf-8 -*-
-require File.dirname(__FILE__) + '/../../spec_helper'
-require File.dirname(__FILE__) + '/fixtures/classes.rb'
-
-describe "String#dump" do
- ruby_version_is ""..."1.9" do
- # Older versions of MRI wrongly print \b as \010
- it "returns a string with nonprinting charaters replaced by escaped-numeric notation" do
- ("\000".."A").to_a.to_s.dump.should == "\"\\000\\001\\002\\003\\004\\005\\006\\a\\b\\t\\n\\v\\f\\r\\016\\017\\020\\021\\022\\023\\024\\025\\026\\027\\030\\031\\032\\e\\034\\035\\036\\037 !\\\"\\\#$%&'()*+,-./0123456789\""
- end
- end
-
- # This test is different on 1.9 for two reasons: 1) 1.9 uses a different
- # format of escaping, 2) 1.9 changes the output of Array#to_s.
- ruby_version_is "1.9" do
- it "returns a string with nonprinting charaters replaced by \\x notation" do
- ("\000".."A").to_a.join('').should == "\x00\x01\x02\x03\x04\x05\x06\a\b\t\n\v\f\r\x0E\x0F\x10\x11\x12\x13\x14\x15\x16\x17\x18\x19\x1A\e\x1C\x1D\x1E\x1F !\"\#$%&'()*+,-./0123456789:;<=>?@A"
- end
- end
-
- # $KCODE is deprecated on 1.9
- ruby_version_is ""..."1.9" do
- it "ignores the $KCODE setting" do
- old_kcode = $KCODE
-
- begin
- $KCODE = "NONE"
- "äöü".dump.should == "\"\\303\\244\\303\\266\\303\\274\""
-
- $KCODE = "UTF-8"
- "äöü".dump.should == "\"\\303\\244\\303\\266\\303\\274\""
- ensure
- $KCODE = old_kcode
- end
- end
- end
-
- it "taints result when self is tainted" do
- "".taint.dump.tainted?.should == true
- "x".taint.dump.tainted?.should == true
- end
-
- it "returns a subclass instance for subclasses" do
- StringSpecs::MyString.new("hi!").dump.class.should == StringSpecs::MyString
- end
-end
Modified: MacRuby/branches/experimental/string.c
===================================================================
--- MacRuby/branches/experimental/string.c 2009-06-05 21:33:49 UTC (rev 1753)
+++ MacRuby/branches/experimental/string.c 2009-06-05 21:41:38 UTC (rev 1754)
@@ -2656,7 +2656,11 @@
/* result from dump is ASCII */
- return rb_str_new2(q_beg);
+ VALUE res = rb_str_new5(str, q_beg, strlen(q_beg));
+ if (OBJ_TAINTED(str)) {
+ OBJ_TAINT(res);
+ }
+ return res;
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20090605/5b9a68b9/attachment-0001.html>
More information about the macruby-changes
mailing list