Bug 1535647 followup. Adjust the WebIDL parser tests for not supporting nullable constants. r=bzbarsky

This commit is contained in:
Boris Zbarsky 2019-03-15 21:12:10 -04:00
Родитель 6be51098cc
Коммит f992dd0ee2
2 изменённых файлов: 17 добавлений и 10 удалений

Просмотреть файл

@ -12,9 +12,6 @@ expected = [
("::TestConsts::ll", "ll", "LongLong", -8), ("::TestConsts::ll", "ll", "LongLong", -8),
("::TestConsts::t", "t", "Boolean", True), ("::TestConsts::t", "t", "Boolean", True),
("::TestConsts::f", "f", "Boolean", False), ("::TestConsts::f", "f", "Boolean", False),
("::TestConsts::n", "n", "BooleanOrNull", None),
("::TestConsts::nt", "nt", "BooleanOrNull", True),
("::TestConsts::nf", "nf", "BooleanOrNull", False),
("::TestConsts::fl", "fl", "Float", 0.2), ("::TestConsts::fl", "fl", "Float", 0.2),
("::TestConsts::db", "db", "Double", 0.2), ("::TestConsts::db", "db", "Double", 0.2),
("::TestConsts::ufl", "ufl", "UnrestrictedFloat", 0.2), ("::TestConsts::ufl", "ufl", "UnrestrictedFloat", 0.2),
@ -39,9 +36,6 @@ def WebIDLTest(parser, harness):
const long long ll = -010; const long long ll = -010;
const boolean t = true; const boolean t = true;
const boolean f = false; const boolean f = false;
const boolean? n = null;
const boolean? nt = true;
const boolean? nf = false;
const float fl = 0.2; const float fl = 0.2;
const double db = 0.2; const double db = 0.2;
const unrestricted float ufl = 0.2; const unrestricted float ufl = 0.2;
@ -78,3 +72,16 @@ def WebIDLTest(parser, harness):
"Const's value has the same type as the type") "Const's value has the same type as the type")
harness.check(const.value.value, value, "Const value has the right value.") harness.check(const.value.value, value, "Const value has the right value.")
parser = parser.reset()
threw = False
try:
parser.parse("""
interface TestConsts {
const boolean? zero = 0;
};
""")
parser.finish()
except:
threw = True
harness.ok(threw, "Nullable types are not allowed for consts.")

Просмотреть файл

@ -4,15 +4,15 @@ def WebIDLTest(parser, harness):
typedef long? mynullablelong; typedef long? mynullablelong;
interface Foo { interface Foo {
const mylong X = 5; const mylong X = 5;
const mynullablelong Y = 7; void foo(optional mynullablelong arg = 7);
const mynullablelong Z = null; void bar(optional mynullablelong arg = null);
void foo(mylong arg); void baz(mylong arg);
}; };
""") """)
results = parser.finish() results = parser.finish()
harness.check(results[2].members[1].type.name, "LongOrNull", harness.check(results[2].members[1].signatures()[0][1][0].type.name, "LongOrNull",
"Should expand typedefs") "Should expand typedefs")
parser = parser.reset() parser = parser.reset()