Commits

David Schneider committed 495612e

fix sequence asCapitalized to only capitalize first char and leave the rest unchanged

  • Participants
  • Parent commits e3b24ae

Comments (0)

Files changed (2)

     
 @register_method('Sequence', 'asCapitalized')
 def sequence_as_capitalized(space, w_target, w_message, w_context):
-    # c/p from pypy/objspace/std/stringobject.py
+    # based on pypy/objspace/std/stringobject.py
     input = w_target.value
     buffer = [' '] * len(input)
     if len(input) > 0:
 
         for i in range(1, len(input)):
             ch = input[i]
-            if ch.isupper():
-                o = ord(ch) + 32
-                buffer[i] = chr(o)
-            else:
-                buffer[i] = ch
+            buffer[i] = ch
 
     s = space.w_sequence.clone()
     s.value = "".join(buffer)

io/test/test_sequence.py

 
 def test_sequence_as_capitalized():
     inp = '"asdf qerttz" asCapitalized'
+    res, space = interpret(inp)
+    assert res.value == "Asdf qerttz"
+
+    inp = '"fooBar" asCapitalized'
+    res, space = interpret(inp)
+    assert res.value == "FooBar"