mirror of https://github.com/lukechilds/rollup.git
Oskar Segersvärd
9 years ago
4 changed files with 43 additions and 1 deletions
@ -0,0 +1,35 @@ |
|||||
|
var assert = require( 'assert' ); |
||||
|
|
||||
|
module.exports = { |
||||
|
description: 'namespaces should be non-extensible and its properties immutatable and non-configurable', |
||||
|
|
||||
|
exports: function ( exports ) { |
||||
|
const ns = exports.ns; |
||||
|
|
||||
|
function extend ( obj ) { |
||||
|
'use strict'; |
||||
|
obj.newProperty = true; |
||||
|
} |
||||
|
|
||||
|
function reconfigure ( obj ) { |
||||
|
Object.defineProperty( obj, 'a', { value: null } ); |
||||
|
} |
||||
|
|
||||
|
function mutate ( obj ) { |
||||
|
'use strict'; |
||||
|
obj.a = 2; |
||||
|
} |
||||
|
|
||||
|
assert.throws(function () { |
||||
|
extend( ns ); |
||||
|
}); |
||||
|
|
||||
|
assert.throws(function () { |
||||
|
reconfigure( ns ); |
||||
|
}); |
||||
|
|
||||
|
assert.throws(function () { |
||||
|
mutate( ns ); |
||||
|
}); |
||||
|
} |
||||
|
}; |
@ -0,0 +1,5 @@ |
|||||
|
// import * as ns from './mod';
|
||||
|
|
||||
|
// export { ns };
|
||||
|
|
||||
|
export var ns = Object.freeze({ a: 1, b: 2 }); |
@ -0,0 +1,2 @@ |
|||||
|
export var a = 1; |
||||
|
export var b = 2; |
Loading…
Reference in new issue