Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(116)

Unified Diff: third_party/WebKit/Source/bindings/scripts/overload_set_algorithm_test.py

Issue 2731683002: [WebAgentsAPI]: Introduce OverloadSetAdapter. (Closed)
Patch Set: Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/bindings/scripts/overload_set_algorithm.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
new file mode 100644
index 0000000000000000000000000000000000000000..8a25711524c9e7d838f1217385b778c57bb3fd5b
--- /dev/null
+++ b/third_party/WebKit/Source/bindings/scripts/overload_set_algorithm_test.py
@@ -0,0 +1,54 @@
+# Copyright 2017 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+# pylint: disable=import-error,print-statement,relative-import,protected-access
+
+"""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):
+ def test_example_in_comments(self):
+ operation_list = [
+ {'arguments': [{'idl_type_object': 'long', # f1(optional long x)
+ 'is_optional': True,
+ 'is_variadic': False}]},
+ {'arguments': [{'idl_type_object': 'DOMString', # f2(DOMString s)
+ 'is_optional': False,
+ 'is_variadic': False}]},
+ ]
+
+ overload_set = [
+ ({'arguments': [{'idl_type_object': 'long', # f1(long)
+ 'is_optional': True,
+ 'is_variadic': False}]},
+ ('long',),
+ (True,)),
+ ({'arguments': [{'idl_type_object': 'long', # f1()
+ 'is_optional': True,
+ 'is_variadic': False}]},
+ (),
+ ()),
+ ({'arguments': [{'idl_type_object': 'DOMString', # f2(DOMString)
+ 'is_optional': False,
+ 'is_variadic': False}]},
+ ('DOMString',),
+ (False,))]
+
+ self.assertEqual(
+ effective_overload_set(operation_list, MethodContextAdapter()),
+ overload_set)
« no previous file with comments | « third_party/WebKit/Source/bindings/scripts/overload_set_algorithm.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698