Skip to content

Commit bad76cc

Browse files
author
Lenny222
committed
---
yaml --- r: 6943 b: refs/heads/master c: eb0cdc0 h: refs/heads/master i: 6941: 56a22f5 6939: 59804b6 6935: de57d4d 6927: 06761c5 6911: f33e750 v: v3
1 parent c58351f commit bad76cc

File tree

3 files changed

+40
-2
lines changed

3 files changed

+40
-2
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: 47271ab4c85ecc4b7c3f1c079f8bc221a5d7ca0d
2+
refs/heads/master: eb0cdc02e3b443fe119cb4957856a63dbd5923d4

trunk/src/libcore/char.rs

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,26 @@ import is_alphabetic = unicode::derived_property::Alphabetic;
4141
import is_XID_start = unicode::derived_property::XID_Start;
4242
import is_XID_continue = unicode::derived_property::XID_Continue;
4343

44+
/*
45+
Function: is_lowercase
46+
47+
Indicates whether a character is in lower case, defined in terms of the
48+
Unicode General Category 'Ll'.
49+
*/
50+
pure fn is_lowercase(c: char) -> bool {
51+
ret unicode::general_category::Ll(c);
52+
}
53+
54+
/*
55+
Function: is_uppercase
56+
57+
Indicates whether a character is in upper case, defined in terms of the
58+
Unicode General Category 'Lu'.
59+
*/
60+
pure fn is_uppercase(c: char) -> bool {
61+
ret unicode::general_category::Lu(c);
62+
}
63+
4464
/*
4565
Function: is_whitespace
4666
@@ -126,4 +146,4 @@ pure fn cmp(a: char, b: char) -> int {
126146
ret if b > a { -1 }
127147
else if b < a { 1 }
128148
else { 0 }
129-
}
149+
}

trunk/src/test/stdtest/char.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,24 @@ import core::*;
33
use std;
44
import char;
55

6+
#[test]
7+
fn test_is_lowercase() {
8+
assert char::is_lowercase('a');
9+
assert char::is_lowercase('ö');
10+
assert char::is_lowercase('ß');
11+
assert !char::is_lowercase('Ü');
12+
assert !char::is_lowercase('P');
13+
}
14+
15+
#[test]
16+
fn test_is_uppercase() {
17+
assert !char::is_uppercase('h');
18+
assert !char::is_uppercase('ä');
19+
assert !char::is_uppercase('ß');
20+
assert char::is_uppercase('Ö');
21+
assert char::is_uppercase('T');
22+
}
23+
624
#[test]
725
fn test_is_whitespace() {
826
assert char::is_whitespace(' ');

0 commit comments

Comments
 (0)