From 03e862ee1426b3318201db63aa538da30809e417 Mon Sep 17 00:00:00 2001 From: Mike Pennisi Date: Thu, 9 Jul 2015 15:02:04 -0400 Subject: [PATCH] Re-organize generator tests The `test/language/generators/` directory contained a single file that concerned generators derived both from syntactic form and from a built-in function. Refactor this test into two files and place each in the appropriate directory. --- .../instance-restricted-properties.js | 37 +++++++++++++ .../Generator_restricted-properties.js | 54 ------------------- .../generators/restricted-properties.js | 35 ++++++++++++ 3 files changed, 72 insertions(+), 54 deletions(-) create mode 100644 test/built-ins/GeneratorFunction/instance-restricted-properties.js delete mode 100644 test/language/generators/Generator_restricted-properties.js create mode 100644 test/language/statements/generators/restricted-properties.js diff --git a/test/built-ins/GeneratorFunction/instance-restricted-properties.js b/test/built-ins/GeneratorFunction/instance-restricted-properties.js new file mode 100644 index 0000000000..aaccca3088 --- /dev/null +++ b/test/built-ins/GeneratorFunction/instance-restricted-properties.js @@ -0,0 +1,37 @@ +// Copyright (C) 2015 Caitlin Potter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: > + Functions created using GeneratorFunction intrinsic function do not have + own properties "caller" or "arguments", but inherit them from + %FunctionPrototype%. +features: [generators] +---*/ + +var Generator = Object.getPrototypeOf(function*() {}); +var GeneratorFunction = Generator.constructor; +var generator = new GeneratorFunction(); + +assert.sameValue( + generator.hasOwnProperty('caller'), false, 'No "caller" own property' +); +assert.sameValue( + generator.hasOwnProperty('arguments'), false, 'No "arguments" own property' +); + +assert.throws(TypeError, function() { + return generator.caller; +}); + +assert.throws(TypeError, function() { + generator.caller = {}; +}); + +assert.throws(TypeError, function() { + return generator.arguments; +}); + +assert.throws(TypeError, function() { + generator.arguments = {}; +}); diff --git a/test/language/generators/Generator_restricted-properties.js b/test/language/generators/Generator_restricted-properties.js deleted file mode 100644 index 87d57a7528..0000000000 --- a/test/language/generators/Generator_restricted-properties.js +++ /dev/null @@ -1,54 +0,0 @@ -// Copyright (C) 2015 Caitlin Potter. All rights reserved. -// This code is governed by the BSD license found in the LICENSE file. - -/*--- -description: > - Functions created using GeneratorFunction syntactic form do not - have own properties "caller" or "arguments", but inherit them from - %FunctionPrototype%. -features: [generators] ----*/ - -function* generator() {} - -assert.sameValue(generator.hasOwnProperty('caller'), false, 'Functions created using ArrowFunction syntactic form do not have own property "caller"'); -assert.sameValue(generator.hasOwnProperty('arguments'), false, 'Functions created using ArrowFunction syntactic form do not have own property "arguments"'); - -assert.throws(TypeError, function() { - return generator.caller; -}); - -assert.throws(TypeError, function() { - generator.caller = {}; -}); - -assert.throws(TypeError, function() { - return generator.arguments; -}); - -assert.throws(TypeError, function() { - generator.arguments = {}; -}); - -var Generator = Object.getPrototypeOf(generator); -var GeneratorFunction = Generator.constructor; -var newgenerator = new GeneratorFunction(); - -assert.sameValue(newgenerator.hasOwnProperty('caller'), false, 'Generators created using GeneratorFunction constructor do not have own property "caller"'); -assert.sameValue(newgenerator.hasOwnProperty('arguments'), false, 'Generators created using GeneratorFunction constructor do not have own property "arguments"'); - -assert.throws(TypeError, function() { - return newgenerator.caller; -}); - -assert.throws(TypeError, function() { - newgenerator.caller = {}; -}); - -assert.throws(TypeError, function() { - return newgenerator.arguments; -}); - -assert.throws(TypeError, function() { - newgenerator.arguments = {}; -}); diff --git a/test/language/statements/generators/restricted-properties.js b/test/language/statements/generators/restricted-properties.js new file mode 100644 index 0000000000..cecc105bfe --- /dev/null +++ b/test/language/statements/generators/restricted-properties.js @@ -0,0 +1,35 @@ +// Copyright (C) 2015 Caitlin Potter. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +description: > + Functions created using GeneratorFunction syntactic form do not have own + properties "caller" or "arguments", but inherit them from + %FunctionPrototype%. +features: [generators] +---*/ + +function* generator() {} + +assert.sameValue( + generator.hasOwnProperty('caller'), false, 'No "caller" own property' +); +assert.sameValue( + generator.hasOwnProperty('arguments'), false, 'No "arguments" own property' +); + +assert.throws(TypeError, function() { + return generator.caller; +}); + +assert.throws(TypeError, function() { + generator.caller = {}; +}); + +assert.throws(TypeError, function() { + return generator.arguments; +}); + +assert.throws(TypeError, function() { + generator.arguments = {}; +});