File: testStringSubclassBehavior.rb

package info (click to toggle)
jruby 1.5.1-1
  • links: PTS, VCS
  • area: non-free
  • in suites: squeeze
  • size: 46,252 kB
  • ctags: 72,039
  • sloc: ruby: 398,155; java: 169,482; yacc: 3,782; xml: 2,469; ansic: 415; sh: 279; makefile: 78; tcl: 40
file content (45 lines) | stat: -rw-r--r-- 1,531 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
require 'test/minirunit'

class MyString < String
end

str = MyString.new("abcd")
str2 = MyString.new(" \\ndc\\nba\\n ")

test_equal(MyString, str.class)
test_equal(MyString, str2.class)
test_equal(MyString, str[0..2].class) # !!!
test_equal(MyString, str.split(/c/).first.class)
test_equal(MyString, str.split(/c/)[0].class)
str2.each_line do |line|
    test_equal(MyString, line.class) # !!
end

test_equal(MyString, str.upcase.class)
test_equal(MyString, str.downcase.class)
test_equal(MyString, str.capitalize.class)
test_equal(MyString, str.swapcase.class)

test_equal(String, str["bc"].class)
test_equal(MyString, str.strip.class)
test_equal(MyString, str.lstrip.class)
test_equal(MyString, str.rstrip.class)
test_equal(MyString, str.squeeze.class)
test_equal(MyString, str.tr("a","b").class)
test_equal(MyString, str.reverse.class)
test_equal(MyString, str.sub("a","b").class)
test_equal(MyString, str.sub(/a/,"b").class)
test_equal(MyString, str.gsub("a","b").class)
test_equal(MyString, str.gsub(/a/,"b").class)
test_equal(MyString, str.delete("bc").class)
test_equal(MyString, str2.chop.class)
test_equal(MyString, str2.chomp.class)
test_equal(MyString, str.dup.class)
test_equal(MyString, str.clone.class)
test_equal(MyString, str.center(20).class)
test_equal(MyString, str.ljust(20).class)
test_equal(MyString, str.rjust(20).class)
test_equal(MyString, str.scan(/.*/).first.class)
test_equal(MyString, str.slice(2,4).class)
test_equal(MyString, str.gsub('ab','dc').class)
test_equal(MyString, str.sub('sb','cd').class)