summaryrefslogtreecommitdiffstats
path: root/chromium/third_party/catapult/common/py_vulcanize/py_vulcanize/strip_js_comments_unittest.py
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2019-03-05 17:34:47 +0100
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2019-03-06 10:04:14 +0000
commiteaf1da4d961fbbda9455f9af3b23d1af777f43fa (patch)
tree95970599ecee31c4f7f940bc97ac98c61a3d0cad /chromium/third_party/catapult/common/py_vulcanize/py_vulcanize/strip_js_comments_unittest.py
parent38a9a29f4f9436cace7f0e7abf9c586057df8a4e (diff)
BASELINE: Update Chromium to 73.0.3683.64
Change-Id: I76517dc277ba4e16bfd7e098fda3d079656b3b9f Reviewed-by: Michael BrĂ¼ning <michael.bruning@qt.io>
Diffstat (limited to 'chromium/third_party/catapult/common/py_vulcanize/py_vulcanize/strip_js_comments_unittest.py')
-rw-r--r--chromium/third_party/catapult/common/py_vulcanize/py_vulcanize/strip_js_comments_unittest.py54
1 files changed, 54 insertions, 0 deletions
diff --git a/chromium/third_party/catapult/common/py_vulcanize/py_vulcanize/strip_js_comments_unittest.py b/chromium/third_party/catapult/common/py_vulcanize/py_vulcanize/strip_js_comments_unittest.py
new file mode 100644
index 00000000000..685cb824a24
--- /dev/null
+++ b/chromium/third_party/catapult/common/py_vulcanize/py_vulcanize/strip_js_comments_unittest.py
@@ -0,0 +1,54 @@
+#!/usr/bin/env python
+# Copyright (c) 2012 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.
+
+"""Tests for strip_js_comments module."""
+
+import unittest
+
+from py_vulcanize import strip_js_comments
+
+
+# This test case tests a protected method.
+# pylint: disable=W0212
+class JavaScriptStripCommentTests(unittest.TestCase):
+ """Test case for _strip_js_comments and _TokenizeJS."""
+
+ def test_strip_comments(self):
+ self.assertEquals(
+ 'A ', strip_js_comments.StripJSComments('A // foo'))
+ self.assertEquals(
+ 'A bar', strip_js_comments.StripJSComments('A // foo\nbar'))
+ self.assertEquals(
+ 'A b', strip_js_comments.StripJSComments('A /* foo */ b'))
+ self.assertEquals(
+ 'A b', strip_js_comments.StripJSComments('A /* foo\n */ b'))
+
+ def test_tokenize_empty(self):
+ tokens = list(strip_js_comments._TokenizeJS(''))
+ self.assertEquals([], tokens)
+
+ def test_tokenize_nl(self):
+ tokens = list(strip_js_comments._TokenizeJS('\n'))
+ self.assertEquals(['\n'], tokens)
+
+ def test_tokenize_slashslash_comment(self):
+ tokens = list(strip_js_comments._TokenizeJS('A // foo'))
+ self.assertEquals(['A ', '//', ' foo'], tokens)
+
+ def test_tokenize_slashslash_comment_then_newline(self):
+ tokens = list(strip_js_comments._TokenizeJS('A // foo\nbar'))
+ self.assertEquals(['A ', '//', ' foo', '\n', 'bar'], tokens)
+
+ def test_tokenize_cstyle_comment_one_line(self):
+ tokens = list(strip_js_comments._TokenizeJS('A /* foo */'))
+ self.assertEquals(['A ', '/*', ' foo ', '*/'], tokens)
+
+ def test_tokenize_cstyle_comment_multi_line(self):
+ tokens = list(strip_js_comments._TokenizeJS('A /* foo\n*bar\n*/'))
+ self.assertEquals(['A ', '/*', ' foo', '\n', '*bar', '\n', '*/'], tokens)
+
+
+if __name__ == '__main__':
+ unittest.main()