Ejemplo n.º 1
0
    def test_strip_comments(self):
        self.assertEquals('A ', parse_deps._strip_js_comments('A // foo'))

        self.assertEquals('A  b',
                          parse_deps._strip_js_comments('A /* foo */ b'))
        self.assertEquals('A  b',
                          parse_deps._strip_js_comments("""A /* foo
 */ b"""))
Ejemplo n.º 2
0
    def test_strip_comments(self):
        self.assertEquals("A ", parse_deps._strip_js_comments("A // foo"))

        self.assertEquals("A  b",
                          parse_deps._strip_js_comments("A /* foo */ b"))
        self.assertEquals("A  b",
                          parse_deps._strip_js_comments("""A /* foo
 */ b"""))
Ejemplo n.º 3
0
    def test_strip_comments(self):
        self.assertEquals("A ", parse_deps._strip_js_comments("A // foo"))

        self.assertEquals("A  b", parse_deps._strip_js_comments("A /* foo */ b"))
        self.assertEquals(
            "A  b",
            parse_deps._strip_js_comments(
                """A /* foo
 */ b"""
            ),
        )
Ejemplo n.º 4
0
    def test_parse_definition_4(self):
        text = """// 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.

'use strict';

/**
 * @fileoverview TimelineView visualizes TRACE_EVENT events using the
 * tracing.TimelineTrackView component and adds in selection summary and
 * control buttons.
 */
base.requireStylesheet('timeline_view')
base.require('timeline_track_view');
base.require('timeline_analysis');
base.require('overlay');
base.require('trace_event_importer');
base.require('linux_perf_importer');
base.exportsTo('tracing', function() {"""

        module = parse_deps.Module('timeline_view')
        stripped_text = parse_deps._strip_js_comments(text)
        module.parse_definition_(stripped_text)
        self.assertEquals(['timeline_view'], module.style_sheet_names)
        self.assertEquals([
            'timeline_track_view', 'timeline_analysis', 'overlay',
            'trace_event_importer', 'linux_perf_importer'
        ], module.dependent_module_names)
Ejemplo n.º 5
0
  def test_parse_definition_4(self):
    text = """// 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.

'use strict';

/**
 * @fileoverview TimelineView visualizes TRACE_EVENT events using the
 * tracing.TimelineTrackView component and adds in selection summary and
 * control buttons.
 */
base.requireStylesheet('timeline_view')
base.require('timeline_track_view');
base.require('timeline_analysis');
base.require('overlay');
base.require('trace_event_importer');
base.require('linux_perf_importer');
base.exportsTo('tracing', function() {"""

    module = parse_deps.Module('timeline_view')
    stripped_text = parse_deps._strip_js_comments(text)
    module.parse_definition_(stripped_text)
    self.assertEquals(['timeline_view'], module.style_sheet_names);
    self.assertEquals(['timeline_track_view',
                       'timeline_analysis',
                       'overlay',
                       'trace_event_importer',
                       'linux_perf_importer'], module.dependent_module_names);
Ejemplo n.º 6
0
    def test_parse_dependency_with_dots(self):
        text = """base.require('foo.dependency1')
"""
        module = parse_deps.Module('myModule')
        stripped_text = parse_deps._strip_js_comments(text)
        module.parse_definition_(stripped_text)
        self.assertEquals([], module.style_sheet_names)
        self.assertEquals(['foo.dependency1'], module.dependent_module_names)
Ejemplo n.º 7
0
    def test_parse_dependency_with_dots(self):
        text = """base.require('foo.dependency1')
"""
        module = parse_deps.Module("myModule")
        stripped_text = parse_deps._strip_js_comments(text)
        module.parse_definition_(stripped_text)
        self.assertEquals([], module.style_sheet_names)
        self.assertEquals(["foo.dependency1"], module.dependent_module_names)
Ejemplo n.º 8
0
  def test_validate_2(self):
    text = """// blahblahblah

base.require('dependency1');
"""
    module = parse_deps.Module('myModule')
    stripped_text = parse_deps._strip_js_comments(text)
    self.assertRaises(lambda: module.validate_uses_strict_mode_(stripped_text))
Ejemplo n.º 9
0
  def test_parse_empty_definition(self):
    text = """// blahblahblah
'use strict';
"""
    module = parse_deps.Module('myModule')
    stripped_text = parse_deps._strip_js_comments(text)
    module.parse_definition_(stripped_text, decl_required=False)
    self.assertEquals([], module.style_sheet_names);
    self.assertEquals([], module.dependent_module_names);
Ejemplo n.º 10
0
    def test_validate_2(self):
        text = """// blahblahblah

base.require('dependency1');
"""
        module = parse_deps.Module('myModule')
        stripped_text = parse_deps._strip_js_comments(text)
        self.assertRaises(
            lambda: module.validate_uses_strict_mode_(stripped_text))
Ejemplo n.º 11
0
    def test_parse_empty_definition(self):
        text = """// blahblahblah
'use strict';
"""
        module = parse_deps.Module('myModule')
        stripped_text = parse_deps._strip_js_comments(text)
        module.parse_definition_(stripped_text, decl_required=False)
        self.assertEquals([], module.style_sheet_names)
        self.assertEquals([], module.dependent_module_names)
Ejemplo n.º 12
0
    def test_validate_1(self):
        text = """// blahblahblah

'use strict';

base.require('dependency1');
"""
        module = parse_deps.Module('myModule')
        stripped_text = parse_deps._strip_js_comments(text)
        module.validate_uses_strict_mode_(stripped_text)
Ejemplo n.º 13
0
  def test_validate_1(self):
    text = """// blahblahblah

'use strict';

base.require('dependency1');
"""
    module = parse_deps.Module('myModule')
    stripped_text = parse_deps._strip_js_comments(text)
    module.validate_uses_strict_mode_(stripped_text)
Ejemplo n.º 14
0
  def test_parse_definition_3(self):
    text = """// blahblahblah
'use strict';
base.require('dependency1');
//base.require('dependency2');
"""
    module = parse_deps.Module('myModule')
    stripped_text = parse_deps._strip_js_comments(text)
    module.parse_definition_(stripped_text)
    self.assertEquals([], module.style_sheet_names);
    self.assertEquals(['dependency1'], module.dependent_module_names);
Ejemplo n.º 15
0
    def test_parse_definition_3(self):
        text = """// blahblahblah
'use strict';
base.require('dependency1');
//base.require('dependency2');
"""
        module = parse_deps.Module('myModule')
        stripped_text = parse_deps._strip_js_comments(text)
        module.parse_definition_(stripped_text)
        self.assertEquals([], module.style_sheet_names)
        self.assertEquals(['dependency1'], module.dependent_module_names)
Ejemplo n.º 16
0
    def test_parse_definition_missing_semis(self):
        text = """// blahblahblah
'use strict';
base.require('dependency1')
base.require('dependency2');
base.requireStylesheet('myStylesheet')
"""
        module = parse_deps.Module("myModule")
        stripped_text = parse_deps._strip_js_comments(text)
        module.parse_definition_(stripped_text)
        self.assertEquals(["myStylesheet"], module.style_sheet_names)
        self.assertEquals(["dependency1", "dependency2"], module.dependent_module_names)
Ejemplo n.º 17
0
    def test_parse_definition_1(self):
        text = """// blahblahblah
'use strict';
base.require('dependency1');
base.require('dependency2');
base.requireStylesheet('myStylesheet');
base.requireTemplate('myTemplate');
"""
        module = parse_deps.Module('myModule')
        stripped_text = parse_deps._strip_js_comments(text)
        module.parse_definition_(stripped_text)
        self.assertEquals(['myStylesheet'], module.style_sheet_names)
        self.assertEquals(['myTemplate'], module.html_template_names)
        self.assertEquals(['dependency1', 'dependency2'],
                          module.dependent_module_names)
Ejemplo n.º 18
0
  def test_parse_definition_1(self):
    text = """// blahblahblah
'use strict';
base.require('dependency1');
base.require('dependency2');
base.requireStylesheet('myStylesheet');
base.requireTemplate('myTemplate');
"""
    module = parse_deps.Module('myModule')
    stripped_text = parse_deps._strip_js_comments(text)
    module.parse_definition_(stripped_text)
    self.assertEquals(['myStylesheet'], module.style_sheet_names);
    self.assertEquals(['myTemplate'], module.html_template_names);
    self.assertEquals(['dependency1', 'dependency2'],
                      module.dependent_module_names);
Ejemplo n.º 19
0
    def test_parse_definition_with_definition_in_comments(self):
        text = """// SomeComment
/*
 * All subclasses should depend on linux_perf_parser, e.g.
 *
 * base.require('linux_perf_parser');
 * base.exportTo('tracing', function() { });
 *
 */
'use strict';
base.require('dependency1');
base.require('dependency2');
"""
        module = parse_deps.Module("myModule")
        stripped_text = parse_deps._strip_js_comments(text)
        module.parse_definition_(stripped_text)
        self.assertEquals([], module.style_sheet_names)
        self.assertEquals(["dependency1", "dependency2"], module.dependent_module_names)
Ejemplo n.º 20
0
    def test_parse_definition_with_definition_in_comments(self):
        text = """// SomeComment
/*
 * All subclasses should depend on linux_perf_parser, e.g.
 *
 * base.require('linux_perf_parser');
 * base.exportTo('tracing', function() { });
 *
 */
'use strict';
base.require('dependency1');
base.require('dependency2');
"""
        module = parse_deps.Module('myModule')
        stripped_text = parse_deps._strip_js_comments(text)
        module.parse_definition_(stripped_text)
        self.assertEquals([], module.style_sheet_names)
        self.assertEquals(['dependency1', 'dependency2'],
                          module.dependent_module_names)
Ejemplo n.º 21
0
  def test_strip_comments(self):
    self.assertEquals('A ', parse_deps._strip_js_comments('A // foo'))

    self.assertEquals('A  b', parse_deps._strip_js_comments('A /* foo */ b'))
    self.assertEquals('A  b', parse_deps._strip_js_comments("""A /* foo
 */ b"""))