Bug 1915045 Ensure decode tasks are scheduled on BufferingState::Enter() r=media...
[gecko.git] / dom / bindings / parser / tests / test_builtins.py
bloba75a12e814367e47feb1b5d101a97eee77343f52
1 import WebIDL
4 def WebIDLTest(parser, harness):
5 parser.parse(
6 """
7 interface TestBuiltins {
8 attribute boolean b;
9 attribute byte s8;
10 attribute octet u8;
11 attribute short s16;
12 attribute unsigned short u16;
13 attribute long s32;
14 attribute unsigned long u32;
15 attribute long long s64;
16 attribute unsigned long long u64;
18 """
21 results = parser.finish()
23 harness.ok(True, "TestBuiltins interface parsed without error.")
24 harness.check(len(results), 1, "Should be one production")
25 harness.ok(isinstance(results[0], WebIDL.IDLInterface), "Should be an IDLInterface")
26 iface = results[0]
27 harness.check(
28 iface.identifier.QName(), "::TestBuiltins", "Interface has the right QName"
30 harness.check(iface.identifier.name, "TestBuiltins", "Interface has the right name")
31 harness.check(iface.parent, None, "Interface has no parent")
33 members = iface.members
34 harness.check(len(members), 9, "Should be one production")
36 names = ["b", "s8", "u8", "s16", "u16", "s32", "u32", "s64", "u64", "ts"]
37 types = [
38 "Boolean",
39 "Byte",
40 "Octet",
41 "Short",
42 "UnsignedShort",
43 "Long",
44 "UnsignedLong",
45 "LongLong",
46 "UnsignedLongLong",
47 "UnsignedLongLong",
49 for i in range(9):
50 attr = members[i]
51 harness.ok(isinstance(attr, WebIDL.IDLAttribute), "Should be an IDLAttribute")
52 harness.check(
53 attr.identifier.QName(),
54 "::TestBuiltins::" + names[i],
55 "Attr has correct QName",
57 harness.check(attr.identifier.name, names[i], "Attr has correct name")
58 harness.check(str(attr.type), types[i], "Attr type is the correct name")
59 harness.ok(attr.type.isPrimitive(), "Should be a primitive type")