[#12372] Release compatibility/train — Prashant Srinivasan <Prashant.Srinivasan@...>

Hello all,

28 messages 2007/10/03
[#12373] Re: Release compatibility/train — Yukihiro Matsumoto <matz@...> 2007/10/03

Hi,

[#12374] Re: Release compatibility/train — David Flanagan <david@...> 2007/10/03

Yukihiro Matsumoto wrote:

[#12376] Re: Release compatibility/train — Prashant Srinivasan <Prashant.Srinivasan@...> 2007/10/03

[#12377] Re: Release compatibility/train — Yukihiro Matsumoto <matz@...> 2007/10/03

Hi,

[#12382] Re: Release compatibility/train — Charles Oliver Nutter <charles.nutter@...> 2007/10/03

Yukihiro Matsumoto wrote:

[#12385] Re: Release compatibility/train — Yukihiro Matsumoto <matz@...> 2007/10/03

Hi,

[#12388] Re: Release compatibility/train — Charles Oliver Nutter <charles.nutter@...> 2007/10/03

Yukihiro Matsumoto wrote:

[#12389] Re: Release compatibility/train — Yukihiro Matsumoto <matz@...> 2007/10/03

Hi,

[#12406] Re: Release compatibility/train — "David A. Black" <dblack@...> 2007/10/03

Hi --

[#12383] Include Rake in Ruby 1.9 — "NAKAMURA, Hiroshi" <nakahiro@...>

-----BEGIN PGP SIGNED MESSAGE-----

20 messages 2007/10/03

[#12539] Ordered Hashes in 1.9? — Michael Neumann <mneumann@...>

Hi all,

17 messages 2007/10/08
[#12542] Re: Ordered Hashes in 1.9? — Yukihiro Matsumoto <matz@...> 2007/10/08

Hi,

[#12681] Unicode: Progress? — murphy <murphy@...>

Hello!

17 messages 2007/10/15

[#12693] retry: revised 1.9 http patch — Hugh Sasse <hgs@...>

I'm reposting this because I've had little response to this version

11 messages 2007/10/15

[#12697] Range.first is incompatible with Enumerable.first — David Flanagan <david@...>

The new Enumerable.first method is a generalization of Array.first to

11 messages 2007/10/16

[#12754] Improving 'syntax error, unexpected $end, expecting kEND'? — Hugh Sasse <hgs@...>

I've had a look at this, but can't see how to do it: When I get

17 messages 2007/10/18
[#12886] Re: Improving 'syntax error, unexpected $end, expecting kEND'? — David Flanagan <david@...> 2007/10/23

The patch below changes this message to:

[#12758] Encoding::primary_encoding — David Flanagan <david@...>

Hi,

25 messages 2007/10/18
[#12763] Re: Encoding::primary_encoding — Nobuyoshi Nakada <nobu@...> 2007/10/19

Hi,

[#12802] Re: Encoding::primary_encoding — Wolfgang N疆asi-Donner <ed.odanow@...> 2007/10/21

Nobuyoshi Nakada schrieb:

[#12803] Re: Encoding::primary_encoding — Nobuyoshi Nakada <nobu@...> 2007/10/21

Hi,

[#12804] Re: Encoding::primary_encoding — Wolfgang N疆asi-Donner <ed.odanow@...> 2007/10/21

Nobuyoshi Nakada schrieb:

[#12808] Re: Encoding::primary_encoding — Nobuyoshi Nakada <nobu@...> 2007/10/22

Hi,

[#12818] Re: Encoding::primary_encoding — Wolfgang N疆asi-Donner <ed.odanow@...> 2007/10/22

Nobuyoshi Nakada schrieb:

[#12820] Re: Encoding::primary_encoding — "Michal Suchanek" <hramrach@...> 2007/10/22

T24gMjIvMTAvMjAwNywgV29sZmdhbmcgTsOhZGFzaS1Eb25uZXIgPGVkLm9kYW5vd0B3b25hZG8u

[#12823] Re: Encoding::primary_encoding — Wolfgang Nádasi-Donner <ed.odanow@...> 2007/10/22

Michal Suchanek schrieb:

[#12824] Re: Encoding::primary_encoding — Nobuyoshi Nakada <nobu@...> 2007/10/22

Hi,

[#12767] \u escapes in string literals: proof of concept implementation — David Flanagan <david@...>

Back at the end of August, Matz wrote (see

45 messages 2007/10/19
[#12769] Re: \u escapes in string literals: proof of concept implementation — "Nobuyoshi Nakada" <nobu@...> 2007/10/19

Hi,

[#12782] Re: \u escapes in string literals: proof of concept implementation — David Flanagan <david@...> 2007/10/20

Nobuyoshi Nakada wrote:

[#12831] Re: \u escapes in string literals: proof of concept implementation — Yukihiro Matsumoto <matz@...> 2007/10/22

Hi,

[#12841] Re: \u escapes in string literals: proof of concept implementation — David Flanagan <david@...> 2007/10/22

Yukihiro Matsumoto wrote:

[#12862] Re: \u escapes in string literals: proof of concept implementation — Martin Duerst <duerst@...> 2007/10/23

At 04:19 07/10/23, David Flanagan wrote:

[#12864] Re: \u escapes in string literals: proof of concept implementation — David Flanagan <david@...> 2007/10/23

Martin Duerst wrote:

[#12870] Re: \u escapes in string literals: proof of concept implementation — Martin Duerst <duerst@...> 2007/10/23

At 13:10 07/10/23, David Flanagan wrote:

[#12872] Re: \u escapes in string literals: proof of concept implementation — David Flanagan <david@...> 2007/10/23

Martin Duerst wrote:

[#12936] Re: \u escapes in string literals: proof of concept implementation — Yukihiro Matsumoto <matz@...> 2007/10/25

Hi,

[#12980] Re: \u escapes in string literals: proof of concept implementation — David Flanagan <david@...> 2007/10/26

Yukihiro Matsumoto wrote:

[#13028] Re: \u escapes in string literals: proof of concept implementation — Nobuyoshi Nakada <nobu@...> 2007/10/29

Hi,

[#13032] Re: \u escapes in string literals: proof of concept implementation — David Flanagan <david@...> 2007/10/29

Nobuyoshi Nakada wrote:

[#13034] Re: \u escapes in string literals: proof of concept implementation — Nobuyoshi Nakada <nobu@...> 2007/10/29

Hi,

[#13082] Re: \u escapes in string literals: proof of concept implementation — Martin Duerst <duerst@...> 2007/10/30

At 16:46 07/10/29, Nobuyoshi Nakada wrote:

[#13231] Re: \u escapes in string literals: proof of concept implementation — Nobuyoshi Nakada <nobu@...> 2007/11/06

Hi,

[#13234] Re: \u escapes in string literals: proof of concept implementation — Martin Duerst <duerst@...> 2007/11/06

At 11:29 07/11/06, Nobuyoshi Nakada wrote:

[#12825] clarification of ruby libraries installation paths? — Lucas Nussbaum <lucas@...>

Hi,

53 messages 2007/10/22
[#12830] Re: clarification of ruby libraries installation paths? — Ben Bleything <ben@...> 2007/10/22

On Mon, Oct 22, 2007, Lucas Nussbaum wrote:

[#12833] Re: clarification of ruby libraries installation paths? — Lucas Nussbaum <lucas@...> 2007/10/22

On 23/10/07 at 00:13 +0900, Ben Bleything wrote:

[#12835] Re: clarification of ruby libraries installation paths? — "Austin Ziegler" <halostatue@...> 2007/10/22

On 10/22/07, Lucas Nussbaum <lucas@lucas-nussbaum.net> wrote:

[#12836] Re: clarification of ruby libraries installation paths? — Lucas Nussbaum <lucas@...> 2007/10/22

On 23/10/07 at 01:55 +0900, Austin Ziegler wrote:

[#12888] Re: clarification of ruby libraries installation paths? — Gonzalo Garramu <ggarra@...> 2007/10/23

Lucas Nussbaum wrote:

[#12894] Re: clarification of ruby libraries installation paths? — Lucas Nussbaum <lucas@...> 2007/10/24

On 24/10/07 at 05:14 +0900, Gonzalo Garramu wrote:

[#13057] Re: clarification of ruby libraries installation paths? — Gonzalo Garramu <ggarra@...> 2007/10/29

Lucas Nussbaum wrote:

[#13058] Re: clarification of ruby libraries installation paths? — Lucas Nussbaum <lucas@...> 2007/10/29

On 30/10/07 at 07:28 +0900, Gonzalo Garramu wrote:

[#12848] Re: clarification of ruby libraries installation paths? — Sam Roberts <sroberts@...> 2007/10/22

On Tue, Oct 23, 2007 at 01:55:29AM +0900, Austin Ziegler wrote:

[#12855] Re: clarification of ruby libraries installation paths? — "Austin Ziegler" <halostatue@...> 2007/10/23

On 10/22/07, Sam Roberts <sroberts@uniserve.com> wrote:

[#13016] Re: clarification of ruby libraries installation paths? — bob@... (Bob Proulx) 2007/10/28

Austin Ziegler wrote:

[#13029] Re: clarification of ruby libraries installation paths? — "Austin Ziegler" <halostatue@...> 2007/10/29

On 10/28/07, Bob Proulx <bob@proulx.com> wrote:

[#13054] Austin Ziegler's behaviour (Was: clarification of ruby libraries installation paths?) — Lucas Nussbaum <lucas@...> 2007/10/29

Austin,

[#13055] Re: Austin Ziegler's behaviour (Was: clarification of ruby libraries installation paths?) — "Luis Lavena" <luislavena@...> 2007/10/29

On 10/29/07, Lucas Nussbaum <lucas@lucas-nussbaum.net> wrote:

[#13064] Re: Austin Ziegler's behaviour (Was: clarification of ruby libraries installation paths?) — "Austin Ziegler" <halostatue@...> 2007/10/30

On 10/29/07, Luis Lavena <luislavena@gmail.com> wrote:

[#13066] Re: Austin Ziegler's behaviour (Was: clarification of ruby libraries installation paths?) — "Luis Lavena" <luislavena@...> 2007/10/30

On 10/30/07, Austin Ziegler <halostatue@gmail.com> wrote:

[#13094] Re: Austin Ziegler's behaviour (Was: clarification of ruby libraries installation paths?) — "Rick Bradley" <rick@...> 2007/10/30

Do we think that maybe, just maybe, things went off the rails when the

[#13095] Re: Austin Ziegler's behaviour (Was: clarification of ruby libraries installation paths?) — "Luis Lavena" <luislavena@...> 2007/10/30

On 10/30/07, Rick Bradley <rick@rickbradley.com> wrote:

[#12900] Hopefully Complete List of Possible Encoding Specifications - Existing Ones — Wolfgang Nádasi-Donner <ed.odanow@...>

Dear Ruby 1.9 architects, developers, and testers!

31 messages 2007/10/24
[#12905] Re: Hopefully Complete List of Possible Encoding Specifications - Existing Ones — Yukihiro Matsumoto <matz@...> 2007/10/24

Hi,

[#12907] Re: Hopefully Complete List of Possible Encoding Specifications - Existing Ones — Wolfgang Nádasi-Donner <ed.odanow@...> 2007/10/24

Yukihiro Matsumoto schrieb:

[#12909] Re: Hopefully Complete List of Possible Encoding Specifications - Existing Ones — Yukihiro Matsumoto <matz@...> 2007/10/24

Hi,

[#12940] Re: Hopefully Complete List of Possible Encoding Specifications - Existing Ones — Wolfgang Nádasi-Donner <ed.odanow@...> 2007/10/25
[#12942] Re: Hopefully Complete List of Possible Encoding Specifications - Existing Ones — Wolfgang Nádasi-Donner <ed.odanow@...> 2007/10/25

I have a (hopefully) final question before testing all

[#12948] Re: Hopefully Complete List of Possible Encoding Specifications - Existing Ones — Nobuyoshi Nakada <nobu@...> 2007/10/26

Hi,

[#12951] Fluent programming in Ruby — David Flanagan <david@...>

From the ChangeLog:

16 messages 2007/10/26

[#12996] General hash keys for colon notation — murphy <murphy@...>

Dear language designer(s) and parser wizards,

16 messages 2007/10/28

[#13027] Implementation of "guessUTF" method - final questions — Wolfgang Nádasi-Donner <ed.odanow@...>

Dear Ruby designers, developers, and testers!

22 messages 2007/10/29

[#13069] new Enumerable.butfirst method — David Flanagan <david@...>

Matz,

17 messages 2007/10/30

Re: Unicode: Progress?

From: Nobuyoshi Nakada <nobu@...>
Date: 2007-10-16 08:29:04 UTC
List: ruby-core #12699
Hi,

At Mon, 15 Oct 2007 20:18:03 +0900,
Yukihiro Matsumoto wrote in [ruby-core:12687]:
> |The knowledge about lower/upper case also seems to be included in 1.9's
> |Oniguruma, since /[[:upper:]]/u works as expected for me.
> 
> Oniguruma does case normalization.  Case conversion both way is more
> difficult.  I don't say it's impossible, but please allow us more
> time.

How about this patch?


Index: encoding.c
===================================================================
--- encoding.c	(revision 13717)
+++ encoding.c	(working copy)
@@ -461,4 +461,23 @@ rb_enc_tolower(int c, rb_encoding *enc)
 }
 
+int
+rb_enc_casefold(char *to, const char *p, const char *e, rb_encoding *enc)
+{
+    OnigCaseFoldCodeItem items[ONIGENC_GET_CASE_FOLD_CODES_MAX_NUM];
+    int i, n;
+
+    n = ONIGENC_GET_CASE_FOLD_CODES_BY_STR(enc, 0, (const UChar *)p, (const UChar *)e, items);
+    for (i = 0; i < n; ++i) {
+	if (items[i].code_len == 1) {
+	    rb_enc_mbcput(items[i].code[0], to, enc);
+	    return items[i].byte_len;
+	}
+    }
+    for (n = i = 0; i < items[0].code_len; ++i) {
+	n += rb_enc_mbcput(items[0].code[i], to + n, enc);
+    }
+    return items[0].byte_len;
+}
+
 static VALUE
 enc_to_s(VALUE self)
Index: string.c
===================================================================
--- string.c	(revision 13717)
+++ string.c	(working copy)
@@ -3048,4 +3071,68 @@ rb_str_dump(VALUE str)
 
 
+#define CHANGECASE_SETUP()					\
+    rb_encoding *enc;						\
+    char *s, *send, *t, *b;					\
+    long len;							\
+    int modify = 0, n, c, asciicompat;				\
+    VALUE str = *strp, str2 = str_new(0, 0, RSTRING_LEN(str));	\
+								\
+    *strp = str2;						\
+    enc = rb_enc_get(str);					\
+    asciicompat = rb_enc_asciicompat(enc);			\
+    rb_enc_associate(str2, enc);				\
+    s = RSTRING_PTR(str); send = RSTRING_END(str);		\
+    b = s;							\
+    len = 0
+
+#define CHANGECASE_FINISH()			\
+    if (s > b) {				\
+	MAKEROOM(s - b);			\
+    }						\
+    STR_SET_LEN(str2, len);			\
+    RSTRING_PTR(str2)[len] = 0;			\
+    if (modify) return str2;			\
+    return Qnil
+
+#define MAKEROOM(n) do {			\
+	RESIZE_CAPA(str2, len + (s - b) + (n)); \
+	t = RSTRING_PTR(str2);			\
+	MEMCPY(t + len, b, char, s - b);	\
+	len += s - b;				\
+    } while (0)
+
+#define SWAPCASE(c) ((c) ^ 0x20)
+
+#define CHANGECASE(ct)					\
+    c = rb_enc_codepoint(s, send, enc);			\
+    if (asciicompat && isascii(c) && ct(c)) {		\
+	MAKEROOM(1);					\
+	t[len++] = SWAPCASE(c);				\
+	b = ++s;					\
+	modify = 1;					\
+    }							\
+    else if (rb_enc_##ct(c, enc)) {			\
+	MAKEROOM(ONIGENC_CODE_TO_MBC_MAXLEN);		\
+	n = rb_enc_casefold(t + len, s, send, enc);	\
+	if (n > 0) len += n;				\
+	s += rb_enc_codelen(c, enc);			\
+	b = s;						\
+	modify = 1;					\
+    }							\
+    else {						\
+	s += rb_enc_codelen(c, enc);			\
+    }
+
+static VALUE
+str_upcase(VALUE *strp)
+{
+    CHANGECASE_SETUP();
+    while (s < send) {
+	CHANGECASE(islower);
+    }
+    CHANGECASE_FINISH();
+}
+
+
 /*
  *  call-seq:
@@ -3060,24 +3147,9 @@ static VALUE
 rb_str_upcase_bang(VALUE str)
 {
-    rb_encoding *enc;
-    char *s, *send;
-    int modify = 0;
-
+    VALUE str2 = str;
     rb_str_modify(str);
-    enc = rb_enc_get(str);
-    s = RSTRING_PTR(str); send = RSTRING_END(str);
-    while (s < send) {
-	int c = rb_enc_codepoint(s, send, enc);
-
-	if (rb_enc_islower(c, enc)) {
-	    /* assuming toupper returns codepoint with same size */
-	    rb_enc_mbcput(rb_enc_toupper(c, enc), s, enc);
-	    modify = 1;
-	}
-	s += rb_enc_codelen(c, enc);
-    }
-
-    if (modify) return str;
-    return Qnil;
+    if (NIL_P(str_upcase(&str2))) return Qnil;
+    rb_str_replace(str, str2);
+    return str;
 }
 
@@ -3098,10 +3170,22 @@ static VALUE
 rb_str_upcase(VALUE str)
 {
-    str = rb_str_dup(str);
-    rb_str_upcase_bang(str);
+    VALUE klass = RBASIC(str)->klass;
+    str_upcase(&str);
+    RBASIC(str)->klass = klass;
     return str;
 }
 
 
+static VALUE
+str_downcase(VALUE *strp)
+{
+    CHANGECASE_SETUP();
+    while (s < send) {
+	CHANGECASE(isupper);
+    }
+    CHANGECASE_FINISH();
+}
+
+
 /*
  *  call-seq:
@@ -3116,24 +3200,9 @@ static VALUE
 rb_str_downcase_bang(VALUE str)
 {
-    rb_encoding *enc;
-    char *s, *send;
-    int modify = 0;
-
+    VALUE str2 = str;
     rb_str_modify(str);
-    enc = rb_enc_get(str);
-    s = RSTRING_PTR(str); send = RSTRING_END(str);
-    while (s < send) {
-	int c = rb_enc_codepoint(s, send, enc);
-
-	if (rb_enc_isupper(c, enc)) {
-	    /* assuming toupper returns codepoint with same size */
-	    rb_enc_mbcput(rb_enc_tolower(c, enc), s, enc);
-	    modify = 1;
-	}
-	s += rb_enc_codelen(c, enc);
-    }
-
-    if (modify) return str;
-    return Qnil;
+    if (NIL_P(str_downcase(&str2))) return Qnil;
+    rb_str_replace(str, str2);
+    return str;
 }
 
@@ -3154,10 +3223,23 @@ static VALUE
 rb_str_downcase(VALUE str)
 {
-    str = rb_str_dup(str);
-    rb_str_downcase_bang(str);
+    VALUE klass = RBASIC(str)->klass;
+    str_downcase(&str);
+    RBASIC(str)->klass = klass;
     return str;
 }
 
 
+static VALUE
+str_capitalize(VALUE *strp)
+{
+    CHANGECASE_SETUP();
+    CHANGECASE(islower);
+    while (s < send) {
+	CHANGECASE(isupper);
+    }
+    CHANGECASE_FINISH();
+}
+
+
 /*
  *  call-seq:
@@ -3177,30 +3259,9 @@ static VALUE
 rb_str_capitalize_bang(VALUE str)
 {
-    rb_encoding *enc;
-    char *s, *send;
-    int modify = 0;
-    int c;
-
+    VALUE str2 = str;
     rb_str_modify(str);
-    enc = rb_enc_get(str);
-    if (RSTRING_LEN(str) == 0 || !RSTRING_PTR(str)) return Qnil;
-    s = RSTRING_PTR(str); send = RSTRING_END(str);
-
-    c = rb_enc_codepoint(s, send, enc);
-    if (rb_enc_islower(c, enc)) {
-	rb_enc_mbcput(rb_enc_toupper(c, enc), s, enc);
-	modify = 1;
-    }
-    s += rb_enc_codelen(c, enc);
-    while (s < send) {
-	c = rb_enc_codepoint(s, send, enc);
-	if (rb_enc_isupper(c, enc)) {
-	    rb_enc_mbcput(rb_enc_tolower(c, enc), s, enc);
-	    modify = 1;
-	}
-	s += rb_enc_codelen(c, enc);
-    }
-    if (modify) return str;
-    return Qnil;
+    if (NIL_P(str_capitalize(&str2))) return Qnil;
+    rb_str_replace(str, str2);
+    return str;
 }
 
@@ -3222,10 +3283,22 @@ static VALUE
 rb_str_capitalize(VALUE str)
 {
-    str = rb_str_dup(str);
-    rb_str_capitalize_bang(str);
+    VALUE klass = RBASIC(str)->klass;
+    str_capitalize(&str);
+    RBASIC(str)->klass = klass;
     return str;
 }
 
 
+static VALUE
+str_swapcase(VALUE *strp)
+{
+    CHANGECASE_SETUP();
+    while (s < send) {
+	CHANGECASE(isalpha);
+    }
+    CHANGECASE_FINISH();
+}
+
+
 /*
  *  call-seq:
@@ -3240,29 +3313,9 @@ static VALUE
 rb_str_swapcase_bang(VALUE str)
 {
-    rb_encoding *enc;
-    char *s, *send;
-    int modify = 0;
-
+    VALUE str2 = str;
     rb_str_modify(str);
-    enc = rb_enc_get(str);
-    s = RSTRING_PTR(str); send = RSTRING_END(str);
-    while (s < send) {
-	int c = rb_enc_codepoint(s, send, enc);
-
-	if (rb_enc_isupper(c, enc)) {
-	    /* assuming toupper returns codepoint with same size */
-	    rb_enc_mbcput(rb_enc_tolower(c, enc), s, enc);
-	    modify = 1;
-	}
-	else if (rb_enc_islower(c, enc)) {
-	    /* assuming toupper returns codepoint with same size */
-	    rb_enc_mbcput(rb_enc_toupper(c, enc), s, enc);
-	    modify = 1;
-	}
-	s += rb_enc_codelen(c, enc);
-    }
-
-    if (modify) return str;
-    return Qnil;
+    if (NIL_P(str_swapcase(&str2))) return Qnil;
+    rb_str_replace(str, str2);
+    return str;
 }
 
@@ -3283,6 +3336,7 @@ static VALUE
 rb_str_swapcase(VALUE str)
 {
-    str = rb_str_dup(str);
-    rb_str_swapcase_bang(str);
+    VALUE klass = RBASIC(str)->klass;
+    str_swapcase(&str);
+    RBASIC(str)->klass = klass;
     return str;
 }
Index: include/ruby/encoding.h
===================================================================
--- include/ruby/encoding.h	(revision 13717)
+++ include/ruby/encoding.h	(working copy)
@@ -95,4 +95,5 @@ int rb_enc_codelen(int, rb_encoding*);
 #define rb_enc_asciicompat(enc) (rb_enc_mbminlen(enc)==1)
 
+int rb_enc_casefold(char *to, const char *p, const char *e, rb_encoding *enc);
 int rb_enc_toupper(int c, rb_encoding *enc);
 int rb_enc_tolower(int c, rb_encoding *enc);
Index: test/ruby/test_encoding.rb
===================================================================
--- test/ruby/test_encoding.rb	(revision 13717)
+++ test/ruby/test_encoding.rb	(working copy)
@@ -26,3 +26,66 @@ class TestEncoding < Test::Unit::TestCas
     end    
   end
+
+  # lettercase
+  UPSTR = "R\303\234BY".force_encoding("utf-8")
+  LOWSTR = "r\303\274by".force_encoding("utf-8")
+  CAPSTR = "R\303\274by".force_encoding("utf-8")
+  MIXSTR = "r\303\234By".force_encoding("utf-8")
+  MIX2STR = "R\303\274bY".force_encoding("utf-8")
+
+  def test_upcase
+    assert_equal(UPSTR, UPSTR.upcase)
+    assert_equal(UPSTR, LOWSTR.upcase)
+    assert_equal(UPSTR, CAPSTR.upcase)
+    assert_equal(UPSTR, MIXSTR.upcase)
+  end
+
+  def test_downcase
+    assert_equal(LOWSTR, UPSTR.downcase)
+    assert_equal(LOWSTR, LOWSTR.downcase)
+    assert_equal(LOWSTR, CAPSTR.downcase)
+    assert_equal(LOWSTR, MIXSTR.downcase)
+  end
+
+  def test_capitalize
+    assert_equal(CAPSTR, UPSTR.capitalize)
+    assert_equal(CAPSTR, LOWSTR.capitalize)
+    assert_equal(CAPSTR, CAPSTR.capitalize)
+    assert_equal(CAPSTR, MIXSTR.capitalize)
+  end
+
+  def test_swapcase
+    assert_equal(LOWSTR, UPSTR.swapcase)
+    assert_equal(UPSTR, LOWSTR.swapcase)
+    assert_equal(MIX2STR, MIXSTR.swapcase)
+    assert_equal(MIXSTR, MIX2STR.swapcase)
+  end
+
+  def test_upcase!
+    assert_nil(UPSTR.dup.upcase!)
+    assert_equal(UPSTR, LOWSTR.dup.upcase!)
+    assert_equal(UPSTR, CAPSTR.dup.upcase!)
+    assert_equal(UPSTR, MIXSTR.dup.upcase!)
+  end
+
+  def test_downcase!
+    assert_equal(LOWSTR, UPSTR.dup.downcase!)
+    assert_nil(LOWSTR.dup.downcase!)
+    assert_equal(LOWSTR, CAPSTR.dup.downcase!)
+    assert_equal(LOWSTR, MIXSTR.dup.downcase!)
+  end
+
+  def test_capitalize!
+    assert_equal(CAPSTR, UPSTR.dup.capitalize!)
+    assert_equal(CAPSTR, LOWSTR.dup.capitalize!)
+    assert_nil(CAPSTR.dup.capitalize!)
+    assert_equal(CAPSTR, MIXSTR.dup.capitalize!)
+  end
+
+  def test_swapcase!
+    assert_equal(LOWSTR, UPSTR.dup.swapcase!)
+    assert_equal(UPSTR, LOWSTR.dup.swapcase!)
+    assert_equal(MIX2STR, MIXSTR.dup.swapcase!)
+    assert_equal(MIXSTR, MIX2STR.dup.swapcase!)
+  end
 end


-- 
Nobu Nakada

In This Thread