dom/bindings/parser/tests/test_extended_attributes.py

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

michael@0 1 import WebIDL
michael@0 2
michael@0 3 def WebIDLTest(parser, harness):
michael@0 4 parser.parse("""
michael@0 5 [NoInterfaceObject]
michael@0 6 interface TestExtendedAttr {
michael@0 7 [Unforgeable] readonly attribute byte b;
michael@0 8 };
michael@0 9 """)
michael@0 10
michael@0 11 results = parser.finish()
michael@0 12
michael@0 13 parser = parser.reset()
michael@0 14 parser.parse("""
michael@0 15 [Pref="foo.bar",Pref=flop]
michael@0 16 interface TestExtendedAttr {
michael@0 17 [Pref="foo.bar"] attribute byte b;
michael@0 18 };
michael@0 19 """)
michael@0 20
michael@0 21 results = parser.finish()
michael@0 22
michael@0 23 parser = parser.reset()
michael@0 24 parser.parse("""
michael@0 25 interface TestLenientThis {
michael@0 26 [LenientThis] attribute byte b;
michael@0 27 };
michael@0 28 """)
michael@0 29
michael@0 30 results = parser.finish()
michael@0 31 harness.ok(results[0].members[0].hasLenientThis(),
michael@0 32 "Should have a lenient this")
michael@0 33
michael@0 34 parser = parser.reset()
michael@0 35 threw = False
michael@0 36 try:
michael@0 37 parser.parse("""
michael@0 38 interface TestLenientThis2 {
michael@0 39 [LenientThis=something] attribute byte b;
michael@0 40 };
michael@0 41 """)
michael@0 42 results = parser.finish()
michael@0 43 except:
michael@0 44 threw = True
michael@0 45
michael@0 46 harness.ok(threw, "[LenientThis] must take no arguments")
michael@0 47
michael@0 48 parser = parser.reset()
michael@0 49 parser.parse("""
michael@0 50 interface TestClamp {
michael@0 51 void testClamp([Clamp] long foo);
michael@0 52 void testNotClamp(long foo);
michael@0 53 };
michael@0 54 """)
michael@0 55
michael@0 56 results = parser.finish()
michael@0 57 # Pull out the first argument out of the arglist of the first (and
michael@0 58 # only) signature.
michael@0 59 harness.ok(results[0].members[0].signatures()[0][1][0].clamp,
michael@0 60 "Should be clamped")
michael@0 61 harness.ok(not results[0].members[1].signatures()[0][1][0].clamp,
michael@0 62 "Should not be clamped")
michael@0 63
michael@0 64 parser = parser.reset()
michael@0 65 threw = False
michael@0 66 try:
michael@0 67 parser.parse("""
michael@0 68 interface TestClamp2 {
michael@0 69 void testClamp([Clamp=something] long foo);
michael@0 70 };
michael@0 71 """)
michael@0 72 results = parser.finish()
michael@0 73 except:
michael@0 74 threw = True
michael@0 75
michael@0 76 harness.ok(threw, "[Clamp] must take no arguments")
michael@0 77
michael@0 78 parser = parser.reset()
michael@0 79 parser.parse("""
michael@0 80 interface TestEnforceRange {
michael@0 81 void testEnforceRange([EnforceRange] long foo);
michael@0 82 void testNotEnforceRange(long foo);
michael@0 83 };
michael@0 84 """)
michael@0 85
michael@0 86 results = parser.finish()
michael@0 87 # Pull out the first argument out of the arglist of the first (and
michael@0 88 # only) signature.
michael@0 89 harness.ok(results[0].members[0].signatures()[0][1][0].enforceRange,
michael@0 90 "Should be enforceRange")
michael@0 91 harness.ok(not results[0].members[1].signatures()[0][1][0].enforceRange,
michael@0 92 "Should not be enforceRange")
michael@0 93
michael@0 94 parser = parser.reset()
michael@0 95 threw = False
michael@0 96 try:
michael@0 97 parser.parse("""
michael@0 98 interface TestEnforceRange2 {
michael@0 99 void testEnforceRange([EnforceRange=something] long foo);
michael@0 100 };
michael@0 101 """)
michael@0 102 results = parser.finish()
michael@0 103 except:
michael@0 104 threw = True
michael@0 105
michael@0 106 harness.ok(threw, "[EnforceRange] must take no arguments")
michael@0 107

mercurial