From e79d57c17f3dadd064e7a2582fad0a0e122de6e1 Mon Sep 17 00:00:00 2001 From: oleg dashevskii Date: Fri, 1 Feb 2008 21:03:08 +0600 Subject: [PATCH] Heredocs and more stuff added to string_spec. --- spec/ruby/1.8/language/string_spec.rb | 114 ++++++++++++++++++++++++-------- 1 files changed, 85 insertions(+), 29 deletions(-) diff --git a/spec/ruby/1.8/language/string_spec.rb b/spec/ruby/1.8/language/string_spec.rb index f12a2b5..27fdb12 100644 --- a/spec/ruby/1.8/language/string_spec.rb +++ b/spec/ruby/1.8/language/string_spec.rb @@ -2,46 +2,40 @@ require File.dirname(__FILE__) + '/../spec_helper' # Thanks http://www.zenspider.com/Languages/Ruby/QuickRef.html -# TODO : HEREDOC -# <.should == "hey xxx" + %!hey #{@ip}!.should == "hey xxx" + %@hey #{@ip}@.should == "hey xxx" %#hey hey#.should == "hey hey" - %|hey hey|.should == "hey hey" - %.should == "hey hey" - %_hey hey_.should == "hey hey" - %.hey hey..should == "hey hey" - %/hey hey/.should == "hey hey" + %%hey #{@ip}%.should == "hey xxx" + %^hey #{@ip}^.should == "hey xxx" + %&hey #{@ip}&.should == "hey xxx" + %*hey #{@ip}*.should == "hey xxx" + %-hey #{@ip}-.should == "hey xxx" + %_hey #{@ip}_.should == "hey xxx" + %=hey #{@ip}=.should == "hey xxx" + %+hey #{@ip}+.should == "hey xxx" + %~hey #{@ip}~.should == "hey xxx" + %:hey #{@ip}:.should == "hey xxx" + %;hey #{@ip};.should == "hey xxx" + %"hey #{@ip}".should == "hey xxx" + %|hey #{@ip}|.should == "hey xxx" + %?hey #{@ip}?.should == "hey xxx" + %/hey #{@ip}/.should == "hey xxx" + %,hey #{@ip},.should == "hey xxx" + %.hey #{@ip}..should == "hey xxx" + + # surprised? huh + %'hey #{@ip}'.should == "hey xxx" + %\hey #{@ip}\.should == "hey xxx" + %`hey #{@ip}`.should == "hey xxx" + %$hey #{@ip}$.should == "hey xxx" end - it "using percent with 'q' should stop interpolation" do + it "using percent with 'q', stopping interpolation" do %q(#{@ip}).should == '#{@ip}' end - # NOTE : I'm not sure why this is needed. IMHO it's redundant with %(). - it "using percent with 'Q' should force interpolation" do + it "using percent with 'Q' to interpolate" do %Q(#{@ip}).should == 'xxx' end @@ -87,4 +98,49 @@ describe "Ruby character strings in various ways" do '\t\n\r\f\b\a\e =b\030'.should == "\\t\\n\\r\\f\\b\\a\\e =b\\030" end + it "allow HEREDOC with <