Skip to content

Commit

Permalink
Fixed String.prototype.toCharArray to use real chars instead of char …
Browse files Browse the repository at this point in the history
…codes and added unit test.
  • Loading branch information
corbanbrook committed Mar 24, 2010
1 parent 6c3d75f commit 57a7f32
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion processing.js
Original file line number Diff line number Diff line change
Expand Up @@ -3106,7 +3106,7 @@
String.prototype.toCharArray = function() {
var chars = this.split("");
for (var i = chars.length -1; i >= 0; i--) {
chars[i] = chars[i].charCodeAt(0);
chars[i] = new Char(chars[i]);
}
return chars;
};
Expand Down
5 changes: 5 additions & 0 deletions test/unit/toCharArray.pde
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
char[] chars = "hello".toCharArray();

_checkEqual(chars[0].toString(), "h");
_checkEqual(chars[1], 101);
_checkEqual(chars[chars.length-1].toString(), "o");

0 comments on commit 57a7f32

Please sign in to comment.