Ejemplo n.º 1
0
    def test_declaration_funcs(self):
        funcStrings = {
            'start of line': "function ball(){"
            }

        for descr, test_string in funcStrings.iteritems():
            self.assertTrue(jsParser.properFunc(test_string), descr)


        self.assertFalse(jsParser.properFunc('zit.forEach(function zitForEach(item){'), 'an inline func declaration')
Ejemplo n.º 2
0
    def test_new_funcs(self):
        funcStrings = {
            'odd case at beginning of line': "New function()",
            'typical': "var zol= New Function()"
            }

        for descr, test_string in funcStrings.iteritems():
            self.assertFalse(jsParser.properFunc(test_string), descr)
Ejemplo n.º 3
0
    def test_anon_funcs(self):
        funcStrings = {
            'inline callback': "this.el.$modalWelcomeBtn.on('click', goog.bind(Function(){}, this));",
            'define optional callback': 'var fn = opt_fn || function(){};'
            }

        for descr, test_string in funcStrings.iteritems():
            self.assertFalse(jsParser.properFunc(test_string), descr)
Ejemplo n.º 4
0
    def test_expression_funcs(self):
        funcStrings = {
            'typical': "ball.app = function()",
            'another expression': "   an.expression.func = function(){}",
            'inside an object with string literal': "  'keyInAnObject' : function() {}",
            'inside an object': "   keyInAnObject : function(){}            "
            }

        for descr, test_string in funcStrings.iteritems():
            self.assertTrue(jsParser.properFunc(test_string), descr)
Ejemplo n.º 5
0
    def test_iffy_funcs(self):
        funcStrings = {
            'full':  "(function(){})()",
            'bang':  "!function(){",
            'bang space':  "!function() {",
            'bang space with params':  "!function(opt_zoid, lor) {",
            'dash': "-function(){",
            'plus': "+function(){",
            'tilde': "~function(){"
        }

        for descr, test_string in funcStrings.iteritems():
            self.assertFalse(jsParser.properFunc(test_string), descr)