Comparing version 0.1.1 to 0.1.2
@@ -90,2 +90,10 @@ 'use strict'; | ||
Context.prototype.lsh = function (left, right) { | ||
return left << right; | ||
}; | ||
Context.prototype.rsh = function (left, right) { | ||
return left >> right; | ||
}; | ||
Context.prototype.add = function (left, right) { | ||
@@ -112,2 +120,14 @@ return this.checkOverflow(left + right); | ||
Context.prototype.band = function (left, right) { | ||
return left & right; | ||
}; | ||
Context.prototype.bor = function (left, right) { | ||
return left | right; | ||
}; | ||
Context.prototype.bxor = function (left, right) { | ||
return left ^ right; | ||
}; | ||
Context.prototype.neg = function (value) { | ||
@@ -117,2 +137,6 @@ return this.checkOverflow(-value); | ||
Context.prototype.bnot = function (value) { | ||
return ~value; | ||
}; | ||
Context.prototype.not = function (value) { | ||
@@ -168,2 +192,22 @@ return !value ? 1 : 0; | ||
Context.prototype.lshAt = function (values, index, value) { | ||
values[this.checkIndex(index, values.length)] = this.lsh(values[index], value); | ||
}; | ||
Context.prototype.rshAt = function (values, index, value) { | ||
values[this.checkIndex(index, values.length)] = this.rsh(values[index], value); | ||
}; | ||
Context.prototype.bandAt = function (values, index, value) { | ||
values[this.checkIndex(index, values.length)] = this.band(values[index], value); | ||
}; | ||
Context.prototype.borAt = function (values, index, value) { | ||
values[this.checkIndex(index, values.length)] = this.bor(values[index], value); | ||
}; | ||
Context.prototype.bxorAt = function (values, index, value) { | ||
values[this.checkIndex(index, values.length)] = this.bxor(values[index], value); | ||
}; | ||
Context.prototype.checkIndex = function (index, length) { | ||
@@ -170,0 +214,0 @@ if (index < 0 || index >= length) { |
@@ -13,2 +13,4 @@ 'use strict'; | ||
'>': 'gt', | ||
'<<': 'lsh', | ||
'>>': 'rsh', | ||
'+': 'add', | ||
@@ -19,2 +21,5 @@ '-': 'sub', | ||
'%': 'rem', | ||
'&': 'band', | ||
'|': 'bor', | ||
'^': 'bxor', | ||
}; | ||
@@ -24,2 +29,3 @@ | ||
'-': 'neg', | ||
'~': 'bnot', | ||
'!': 'not', | ||
@@ -26,0 +32,0 @@ '$': 'len', |
{ | ||
"name": "introjs", | ||
"version": "0.1.1", | ||
"version": "0.1.2", | ||
"description": "IntroJS is a JavaScript implementation of the simplified programming language Intro.", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -145,3 +145,2 @@ # IntroJS | ||
* Bit operators | ||
* Hexadecimal literal | ||
@@ -148,0 +147,0 @@ * Multidimensional array |
@@ -43,2 +43,16 @@ 'use strict'; | ||
it('lsh', function () { | ||
assert.strictEqual(ctx.lsh(5, 0), 5); | ||
assert.strictEqual(ctx.lsh(5, 1), 10); | ||
assert.strictEqual(ctx.lsh(5, 2), 20); | ||
assert.strictEqual(ctx.lsh(2147483647, 1), -2); | ||
}); | ||
it('rsh', function () { | ||
assert.strictEqual(ctx.rsh(5, 0), 5); | ||
assert.strictEqual(ctx.rsh(5, 1), 2); | ||
assert.strictEqual(ctx.rsh(5, 2), 1); | ||
assert.strictEqual(ctx.rsh(5, 3), 0); | ||
}); | ||
it('add', function () { | ||
@@ -202,2 +216,14 @@ assert.strictEqual(ctx.add(5, 2), 7); | ||
it('lshAt', function () { | ||
var values = [1, 5]; | ||
ctx.lshAt(values, 1, 1); | ||
assert.deepStrictEqual(values, [1, 10]) | ||
}); | ||
it('rshAt', function () { | ||
var values = [1, 5]; | ||
ctx.rshAt(values, 1, 1); | ||
assert.deepStrictEqual(values, [1, 2]) | ||
}); | ||
describe('range', function () { | ||
@@ -204,0 +230,0 @@ it('0 :< 4', function () { |
@@ -10,2 +10,4 @@ 'use strict'; | ||
'./examples/sum/sum.intro', | ||
'./test/assignments/assignments.intro', | ||
'./test/expressions/expressions.intro', | ||
]; | ||
@@ -12,0 +14,0 @@ sourceFilePaths.forEach(function (sourceFilePath) { |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
186563
69
5635
168