コード例 #1
0
 def test_extract_on_syntax_error(self):
     with self.assertRaises(SyntaxError):
         requirejs.extract_function_argument(
             """
         (function() {
             console.log('hello!');
             report('');
             missing_rparen(1, 2, 'hello';
         })();
         """, 'report', 0)
コード例 #2
0
 def test_extract_function_argument_mismatches(self):
     results = requirejs.extract_function_argument(
         """
     trial(1, 2);
     trial(1, 2, 23, 4, 5);
     """, 'trial', 2)
     self.assertEqual(results, [])
コード例 #3
0
 def test_extract_function_argument_basic(self):
     results = requirejs.extract_function_argument(
         """
     trial(1, 2, 'hello');
     trial(1, 2, "goodbye");
     """, 'trial', 2)
     self.assertEqual(results, ['hello', 'goodbye'])
コード例 #4
0
 def test_extract_function_argument_not_nested(self):
     results = requirejs.extract_function_argument(
         """
     (function() {
         trial(1, 2, 'hello', trial(1, 2, 'goodbye'));
         trial(1, 2, (function() { trial(1, 2, 'goodbye')})());
     })();
     """, 'trial', 2)
     self.assertEqual(results, ['hello'])
コード例 #5
0
 def test_extract_function_not_sub(self):
     results = requirejs.extract_function_argument(
         """
     (function() {
         log('hello');
         log('');
         console.log('goodbye');
     })();
     """, 'log', 0)
     self.assertEqual(results, ['hello', ''])