def test_duplicate(self): with self.assertRaisesRegexp(Exception, "duplicate: foo"): parseTestRecord(""" // Copyright /** * @foo bar * @foo bar */ 1; """ , "name")
def test_malformed(self): with self.assertRaisesRegexp(Exception, 'Malformed "@" attribute: name'): parseTestRecord(""" // Copyright /** * @ baz * @foo bar */ 1; """ , "name")
def test_overview(self): name = 'fixtures/test262-old-headers.js' contents = slurpFile(name) record = parseTestRecord(contents, name) self.assertEqual("""// Copyright 2009 the Sputnik authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file.""", record['header']) self.assertEqual("""The production Block { } in strict code can't contain function declaration;""", record['commentary']) self.assertEqual("bestPractice/Sbp_A1_T1.js", record['path']) self.assertEqual("Trying to declare function at the Block statement", record['description']) self.assertEqual("", record['onlyStrict']) self.assertEqual("SyntaxError", record['negative']) self.assertEqual("http://wiki.ecmascript.org/doku.php?id=conventions:no_non_standard_strict_decls", record['bestPractice']) self.assertEqual(""""use strict"; { function __func(){} } """, record['test'])
def test_negative(self): name = 'fixtures/negative.js' contents = slurpFile(name) record = parseTestRecord(contents, name) self.assertEqual('early', record['negative']['phase']) self.assertEqual('SyntaxError', record['negative']['type'])
def test_overview_no_copyright(self): name = 'fixtures/test262-yaml-headers-no-cr.js' contents = slurpFile(name) record = parseTestRecord(contents, name, print) self.assertEqual('', record['header']) self.assertEqual( "The production Block { } in strict code can't contain function declaration;\n", record['commentary']) self.assertEqual("Trying to declare function at the Block statement", record['description']) self.assertEqual(['onlyStrict'], record['flags']) self.assertEqual("", record['onlyStrict']) self.assertEqual("SyntaxError", record['negative']) self.assertEqual( '"http://wiki.ecmascript.org/doku.php?id=conventions:no_non_standard_strict_decls"', record['bestPractice']) self.assertEqual( dedent_lstrip(""" "use strict"; { function __func(){} } """), record['test'])
def test_overview(self): name = "fixtures/test262-yaml-headers.js" contents = slurpFile(name) record = parseTestRecord(contents, name) self.assertEqual( """// Copyright 2009 the Sputnik authors. All rights reserved. // This code is governed by the BSD license found in the LICENSE file.""", record["header"], ) self.assertEqual( "The production Block { } in strict code can't contain function declaration;\n", record["commentary"] ) self.assertEqual("Trying to declare function at the Block statement", record["description"]) self.assertEqual(["onlyStrict"], record["flags"]) self.assertEqual("", record["onlyStrict"]) self.assertEqual("SyntaxError", record["negative"]) self.assertEqual( "http://wiki.ecmascript.org/doku.php?id=conventions:no_non_standard_strict_decls", record["bestPractice"] ) self.assertEqual( """"use strict"; { function __func(){} } """, record["test"], )
def test_nomatch(self): with self.assertRaisesRegexp(Exception, "unrecognized"): parseTestRecord("#!/usr/bin/env python", "random.py")