diff --git a/test/main.js b/test/main.js index b2262cf..201b0fa 100644 --- a/test/main.js +++ b/test/main.js @@ -28,7 +28,9 @@ var suites = [ './suites/ecma-statements-test.js', './suites/ecma-function-definition-test.js', './suites/ecma-standard-built-in-ecmascript-objects-test.js', - './suites/ecma6-tests/ecma6-template-literals-tests.js' + './suites/ecma6-tests/ecma6-template-literals-tests.js', + './suites/ecma6-tests/ecma6-constants-and-variables-tests.js', + './suites/ecma6-tests/ecma6-map-set-and-weakmap-weakset-tests.js' ]; require(suites, function () { diff --git a/test/suites/ecma6-tests/ecma6-constants-and-variables-tests.js b/test/suites/ecma6-tests/ecma6-constants-and-variables-tests.js new file mode 100644 index 0000000..668703a --- /dev/null +++ b/test/suites/ecma6-tests/ecma6-constants-and-variables-tests.js @@ -0,0 +1,69 @@ +// Copyright (c) 2013 - present UTN-LIS + +/* eslint quotes: 0, no-unused-vars: 0 */ + +/** + * PUMASCRIPT ECMA 6 CONSTANTS AND VARIABLES SUITE + * @file: Ecma6 Constants and variables expressions test suite for the language + */ +var test = QUnit.test; +var skip = QUnit.skip; + +define(['pumascript'], function (puma) { + + QUnit.module("Ecma6-Constants-And-Variables-Tests"); + + skip("Constant", function(assert) { + var result = puma.evalPuma("const PI = 3.141593; PI;"); + result.makeValue(); + assert.ok(result.success && result.value === 3.141593); + }); + + skip("Constant principal scope", function(assert) { + var result = puma.evalPuma("const PI = 3.141593; if(true){const PI = 3.14;} PI;"); + result.makeValue(); + assert.ok(result.success && result.value === 3.141593); + }); + + skip("Constant block scope", function(assert) { + var result = puma.evalPuma("const PI = 3.141593; if(true){const PI = 3.14; PI}"); + result.makeValue(); + assert.ok(result.success && result.value === 3.14); + }); + + skip("Constant principal scope not defined with block scope constant", function(assert) { + var result = puma.evalPuma("if(true){const PI = 3.141593;} typeof(PI);"); + result.makeValue(); + assert.ok(result.success && result.value === 'undefined'); + }); + + skip("Change of a property from a constant as an object", function(assert) { + var result = puma.evalPuma("const p = {first: 'john', last: 'smith'}; p.first = 'bob'; p.first;"); + result.makeValue(); + assert.ok(result.success && result.value === 'bob'); + }); + + skip("Variable let", function(assert) { + var result = puma.evalPuma("let a = 2; a;"); + assert.ok(result.success && result.value === 2); + }); + + skip("Variable let principal scope", function(assert) { + var result = puma.evalPuma("let a = 2; if(true){let a = 3;} a;"); + result.makeValue(); + assert.ok(result.success && result.value === 2); + }); + + skip("Variable let block scope", function(assert) { + var result = puma.evalPuma("let a = 2; if(true){let a = 3; a;}"); + result.makeValue(); + assert.ok(result.success && result.value === 3); + }); + + skip("Variable let principal scope not defined with block scope constant", function(assert) { + var result = puma.evalPuma("if(true){let a = 3;} typeof(a);"); + result.makeValue(); + assert.ok(result.success && result.value === 'undefined'); + }); + +}); diff --git a/test/suites/ecma6-tests/ecma6-map-set-and-weakmap-weakset-tests.js b/test/suites/ecma6-tests/ecma6-map-set-and-weakmap-weakset-tests.js new file mode 100644 index 0000000..0961da6 --- /dev/null +++ b/test/suites/ecma6-tests/ecma6-map-set-and-weakmap-weakset-tests.js @@ -0,0 +1,71 @@ +// Copyright (c) 2013 - present UTN-LIS + +/* eslint quotes: 0, no-unused-vars: 0 */ + +/** + * PUMASCRIPT ECMA 6 MAP-SET AND WEAKMAP-WEAKSET SUITE + * @file: Ecma6 Map-Set and WeakMap-WeakSet expressions test suite for the language + */ +var test = QUnit.test; +var skip = QUnit.skip; + +define(['pumascript'], function (puma) { + + QUnit.module("Ecma6-Map-Set-And-WeakMap-WeakSet-Tests"); + + skip("Map get method", function(assert) { + var result = puma.evalPuma("let m = new Map(); const s = Symbol(); m.set('hello', 42); m.set(s, 34); m.get(s);"); + result.makeValue(); + assert.ok(result.success && result.value === 34); + }); + + skip("Map has method", function(assert) { + var result = puma.evalPuma("let m = new Map(); const s = Symbol(); m.set('hello', 42); m.set(s, 34); m.has(s);"); + result.makeValue(); + assert.ok(result.success && result.value === true); + }); + + skip("Map stores unique keys, check of size", function(assert) { + var result = puma.evalPuma("let m = new Map(); const s = Symbol(); m.set('hello', 42); m.set(s, 34); m.set('hello', 34); m.size;"); + result.makeValue(); + assert.ok(result.success && result.value === 2); + }); + + skip("Map delete method", function(assert) { + var result = puma.evalPuma("let m = new Map(); const s = Symbol(); m.set('hello', 42); m.set(s, 34); m.delete('hello'); m.size;"); + result.makeValue(); + assert.ok(result.success && result.value === 1); + }); + + skip("Map clear method", function(assert) { + var result = puma.evalPuma("let m = new Map(); const s = Symbol(); m.set('hello', 42); m.set(s, 34); m.clear(); m.size;"); + result.makeValue(); + assert.ok(result.success && result.value === 0); + }); + + skip("Set has method", function(assert) { + var result = puma.evalPuma("let s = new Set(); s.add('hello'); s.has('hello');"); + result.makeValue(); + assert.ok(result.success && result.value === true); + }); + + skip("Set stores unique values, check of size", function(assert) { + var result = puma.evalPuma("let s = new Set(); s.add('hello').add('goodbye').add('hello'); s.size;"); + result.makeValue(); + assert.ok(result.success && result.value === 2); + }); + + skip("Set delete method", function(assert) { + var result = puma.evalPuma("let s = new Set(); s.add('hello').add('goodbye'); s.delete('hello'); s.size;"); + result.makeValue(); + assert.ok(result.success && result.value === 1); + }); + + skip("Set clear method", function(assert) { + var result = puma.evalPuma("let s = new Set(); s.add('hello').add('goodbye'); s.clear(); s.size;"); + result.makeValue(); + assert.ok(result.success && result.value === 0); + }); + + //Missing WeakMap and WeakSet tests +});