Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ECMA 6 - Constants and variables and Map/Set tests #139

Merged
merged 13 commits into from
Jun 13, 2018
4 changes: 3 additions & 1 deletion test/main.js
Original file line number Diff line number Diff line change
@@ -27,7 +27,9 @@ var suites = [
'./suites/ecma-expressions-test.js',
'./suites/ecma-statements-test.js',
'./suites/ecma-function-definition-test.js',
'./suites/ecma-standard-built-in-ecmascript-objects-test.js'
'./suites/ecma-standard-built-in-ecmascript-objects-test.js',
'./suites/ecma6-tests/ecma6-constants-and-variables-tests.js',
'./suites/ecma6-tests/ecma6-map-set-and-weakmap-weakset-tests.js'
];

require(suites, function () {
69 changes: 69 additions & 0 deletions test/suites/ecma6-tests/ecma6-constants-and-variables-tests.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
// Copyright (c) 2013 - present UTN-LIS
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review indentation. Please take note of unsupported cases for Puma. This will help to define future tasks on the runtime support.


/* 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');
});

});
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add blank line at EOF

59 changes: 59 additions & 0 deletions test/suites/ecma6-tests/ecma6-map-set-and-weakmap-weakset-tests.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
// 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(); let 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(); let 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(); let 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(); let 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(); let 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);
});

//Missing WeakMap and WeakSet tests
});