Fix underscores for isupper

This commit is contained in:
coolreader18
2019-10-24 22:46:23 -05:00
parent 914299a4bf
commit 368fe7294d
2 changed files with 6 additions and 2 deletions

View File

@@ -324,3 +324,6 @@ assert "a".__ne__("b")
assert not "a".__ne__("a")
assert not "".__ne__("")
assert "".__ne__(1) == NotImplemented
assert "A_B".isupper()
assert "a_b".islower()

View File

@@ -727,11 +727,12 @@ impl PyString {
#[pymethod]
fn isupper(&self, _vm: &VirtualMachine) -> bool {
// TODO: assert not " ".isupper(), assert not "_".isupper()
!self.value.is_empty()
&& self
.value
.chars()
.filter(|x| !x.is_ascii_whitespace())
.filter(|x| !x.is_ascii_whitespace() && *x != '_')
.all(char::is_uppercase)
}
@@ -741,7 +742,7 @@ impl PyString {
&& self
.value
.chars()
.filter(|x| !x.is_ascii_whitespace())
.filter(|x| !x.is_ascii_whitespace() && *x != '_')
.all(char::is_lowercase)
}