Skip to content

Commit

Permalink
Add initial and (more) recent goog.math.long for reference, see dcode…
Browse files Browse the repository at this point in the history
  • Loading branch information
dcodeIO committed Feb 3, 2018
1 parent edab5f1 commit f9a4246
Show file tree
Hide file tree
Showing 9 changed files with 4,224 additions and 39 deletions.
43 changes: 43 additions & 0 deletions tests/goog/base.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// Closure Library compatibility layer

if (typeof global === "undefined") global = window;

var goog = global.goog = {};

goog.require = function(pkg) {};

goog.setTestOnly = function() {};

goog.provide = function(pkg) {
var parts = pkg.split('.');
var current = global;
while (parts.length) {
var part = parts.shift();
current = current[part] || (current[part] = {});
}
};

// Environment required to test both old and new versions of goog.math.long.js

goog.provide("goog.global");

goog.provide("goog.asserts");

goog.asserts.assert = function(condition, opt_message, var_args) {
if (!condition)
throw Error("Assertion error: " + opt_message + " " + Array.prototype.slice.call(arguments, 2));
};

global.assertEquals = function(expected, actual) { goog.asserts.assert(expected === actual); }

global.assertTrue = function(value) { goog.asserts.assert(value === true); }

goog.provide("goog.reflect");

goog.reflect.cache = function(cacheObj, key, valueFn, opt_keyFn) {
var storedKey = opt_keyFn ? opt_keyFn(key) : key;
if (Object.prototype.hasOwnProperty.call(cacheObj, storedKey)) {
return cacheObj[storedKey];
}
return (cacheObj[storedKey] = valueFn(key));
};
24 changes: 24 additions & 0 deletions tests/goog/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
require("./base");

require("./initial/long");
require("./initial/long_test");

console.log("Testing initial goog.math.long.js ...");
Object.keys(goog.global).forEach(function(key) {
if (typeof goog.global[key] === "function") {
console.log("Running '" + key + "' ...");
goog.global[key]();
}
});
goog.global = {};

require("./recent/long");
require("./recent/long_test");

console.log("\nTesting (more) recent goog.math.long.js ...");
Object.keys(goog.global).forEach(function(key) {
if (typeof goog.global[key] === "function") {
console.log("Running '" + key + "' ...");
goog.global[key]();
}
});
1 change: 1 addition & 0 deletions tests/goog/initial/README
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
goog.math.long at the time of bootstrapping long.js
6 changes: 1 addition & 5 deletions tests/goog.math.long.js → tests/goog/initial/long.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@
*
*/

// goog.provide('goog.math.Long');
var goog = {}; goog.math = {};
goog.provide('goog.math.Long');



Expand Down Expand Up @@ -312,7 +311,6 @@ goog.math.Long.prototype.toString = function(opt_radix) {
while (true) {
var remDiv = rem.div(radixToPower);
var intval = rem.subtract(remDiv.multiply(radixToPower)).toInt() >>> 0; // wraps around for base 36 (dcode)
console.log(intval);
var digits = intval.toString(radix);

rem = remDiv;
Expand Down Expand Up @@ -803,5 +801,3 @@ goog.math.Long.prototype.shiftRightUnsigned = function(numBits) {
}
}
};

module.exports = goog.math.Long;
1,549 changes: 1,549 additions & 0 deletions tests/goog/initial/long_test.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions tests/goog/recent/README
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
goog.math.long at 2018/02/03
Loading

0 comments on commit f9a4246

Please sign in to comment.