| Index: third_party/WebKit/Source/bindings/scripts/overload_set_algorithm_test.py
|
| diff --git a/third_party/WebKit/Source/bindings/scripts/overload_set_algorithm_test.py b/third_party/WebKit/Source/bindings/scripts/overload_set_algorithm_test.py
|
| index 8a25711524c9e7d838f1217385b778c57bb3fd5b..389a9ed3e53564f679ccdf59bddf90d7a133489f 100644
|
| --- a/third_party/WebKit/Source/bindings/scripts/overload_set_algorithm_test.py
|
| +++ b/third_party/WebKit/Source/bindings/scripts/overload_set_algorithm_test.py
|
| @@ -7,18 +7,7 @@
|
| """Unit tests for overload_set_algorithm.py."""
|
|
|
| import unittest
|
| -
|
| from overload_set_algorithm import effective_overload_set
|
| -from overload_set_algorithm import MethodContextAdapter
|
| -
|
| -
|
| -class MethodContextAdapterTest(unittest.TestCase):
|
| - def test_simple(self):
|
| - adapter = MethodContextAdapter()
|
| - self.assertEqual(adapter.arguments({'arguments': 'foo'}), 'foo')
|
| - self.assertEqual(adapter.type({'idl_type_object': 'bar'}), 'bar')
|
| - self.assertEqual(adapter.is_optional({'is_optional': 'baz'}), 'baz')
|
| - self.assertEqual(adapter.is_variadic({'is_variadic': 'qux'}), 'qux')
|
|
|
|
|
| class EffectiveOverloadSetTest(unittest.TestCase):
|
| @@ -29,8 +18,7 @@ class EffectiveOverloadSetTest(unittest.TestCase):
|
| 'is_variadic': False}]},
|
| {'arguments': [{'idl_type_object': 'DOMString', # f2(DOMString s)
|
| 'is_optional': False,
|
| - 'is_variadic': False}]},
|
| - ]
|
| + 'is_variadic': False}]}]
|
|
|
| overload_set = [
|
| ({'arguments': [{'idl_type_object': 'long', # f1(long)
|
| @@ -49,6 +37,127 @@ class EffectiveOverloadSetTest(unittest.TestCase):
|
| ('DOMString',),
|
| (False,))]
|
|
|
| - self.assertEqual(
|
| - effective_overload_set(operation_list, MethodContextAdapter()),
|
| - overload_set)
|
| + self.assertEqual(effective_overload_set(operation_list), overload_set)
|
| +
|
| + def test_example_in_spec(self):
|
| + """Tests the example provided in Web IDL spec:
|
| + https://heycam.github.io/webidl/#dfn-effective-overload-set,
|
| + look for example right after the algorithm.
|
| +
|
| + The output differs from spec because we don't implement the part
|
| + of the algorithm that handles variadic arguments."""
|
| + operation_list = [
|
| + # f1: f(DOMString a)
|
| + {'arguments': [{'idl_type_object': 'DOMString',
|
| + 'is_optional': False,
|
| + 'is_variadic': False}]},
|
| + # f2: f(Node a, DOMString b, double... c)
|
| + {'arguments': [{'idl_type_object': 'Node',
|
| + 'is_optional': False,
|
| + 'is_variadic': False},
|
| + {'idl_type_object': 'DOMString',
|
| + 'is_optional': False,
|
| + 'is_variadic': False},
|
| + {'idl_type_object': 'double',
|
| + 'is_optional': False,
|
| + 'is_variadic': True}]},
|
| + # f3: f()
|
| + {'arguments': []},
|
| + # f4: f(Event a, DOMString b, optional DOMString c, double... d)
|
| + {'arguments': [{'idl_type_object': 'Event',
|
| + 'is_optional': False,
|
| + 'is_variadic': False},
|
| + {'idl_type_object': 'DOMString',
|
| + 'is_optional': False,
|
| + 'is_variadic': False},
|
| + {'idl_type_object': 'DOMString',
|
| + 'is_optional': True,
|
| + 'is_variadic': False},
|
| + {'idl_type_object': 'double',
|
| + 'is_optional': False,
|
| + 'is_variadic': True}]}]
|
| + overload_set = [
|
| + # <f1, (DOMString), (required)>
|
| + ({'arguments': [{'idl_type_object': 'DOMString',
|
| + 'is_optional': False,
|
| + 'is_variadic': False}]},
|
| + ('DOMString',),
|
| + (False,)),
|
| + # <f2, (Node, DOMString, double), (required, required, variadic)>
|
| + ({'arguments': [{'idl_type_object': 'Node',
|
| + 'is_optional': False,
|
| + 'is_variadic': False},
|
| + {'idl_type_object': 'DOMString',
|
| + 'is_optional': False,
|
| + 'is_variadic': False},
|
| + {'idl_type_object': 'double',
|
| + 'is_optional': False,
|
| + 'is_variadic': True}]},
|
| + ('Node', 'DOMString', 'double'),
|
| + (False, False, True)),
|
| + # <f2, (Node, DOMString), (required, required)>
|
| + ({'arguments': [{'idl_type_object': 'Node',
|
| + 'is_optional': False,
|
| + 'is_variadic': False},
|
| + {'idl_type_object': 'DOMString',
|
| + 'is_optional': False,
|
| + 'is_variadic': False},
|
| + {'idl_type_object': 'double',
|
| + 'is_optional': False,
|
| + 'is_variadic': True}]},
|
| + ('Node', 'DOMString'),
|
| + (False, False)),
|
| + # Missing from the output:
|
| + # <f2, (Node, DOMString, double, double),
|
| + # (required, required, variadic, variadic)>,
|
| + # <f3, (), ()>
|
| + ({'arguments': []}, (), ()),
|
| + # <f4, (Event, DOMString, DOMString, double),
|
| + # (required, required, optional, variadic)>
|
| + ({'arguments': [{'idl_type_object': 'Event',
|
| + 'is_optional': False,
|
| + 'is_variadic': False},
|
| + {'idl_type_object': 'DOMString',
|
| + 'is_optional': False,
|
| + 'is_variadic': False},
|
| + {'idl_type_object': 'DOMString',
|
| + 'is_optional': True,
|
| + 'is_variadic': False},
|
| + {'idl_type_object': 'double',
|
| + 'is_optional': False,
|
| + 'is_variadic': True}]},
|
| + ('Event', 'DOMString', 'DOMString', 'double'),
|
| + (False, False, True, True)),
|
| + # <f4, (Event, DOMString, DOMString),
|
| + # (required, required, optional)>
|
| + ({'arguments': [{'idl_type_object': 'Event',
|
| + 'is_optional': False,
|
| + 'is_variadic': False},
|
| + {'idl_type_object': 'DOMString',
|
| + 'is_optional': False,
|
| + 'is_variadic': False},
|
| + {'idl_type_object': 'DOMString',
|
| + 'is_optional': True,
|
| + 'is_variadic': False},
|
| + {'idl_type_object': 'double',
|
| + 'is_optional': False,
|
| + 'is_variadic': True}]},
|
| + ('Event', 'DOMString', 'DOMString'),
|
| + (False, False, True)),
|
| + # <f4, (Event, DOMString), (required, required)>
|
| + ({'arguments': [{'idl_type_object': 'Event',
|
| + 'is_optional': False,
|
| + 'is_variadic': False},
|
| + {'idl_type_object': 'DOMString',
|
| + 'is_optional': False,
|
| + 'is_variadic': False},
|
| + {'idl_type_object': 'DOMString',
|
| + 'is_optional': True,
|
| + 'is_variadic': False},
|
| + {'idl_type_object': 'double',
|
| + 'is_optional': False,
|
| + 'is_variadic': True}]},
|
| + ('Event', 'DOMString'),
|
| + (False, False))]
|
| +
|
| + self.assertEqual(effective_overload_set(operation_list), overload_set)
|
|
|