From 62256c5dedf4dbddf62af88e07f05f8d4f72aca5 Mon Sep 17 00:00:00 2001 From: Vadim Senderovich Date: Thu, 11 Oct 2012 10:17:44 +0200 Subject: [PATCH 1/3] added rake test task to Rakefile --- Rakefile | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Rakefile b/Rakefile index 166f76c..537672b 100644 --- a/Rakefile +++ b/Rakefile @@ -55,3 +55,12 @@ var CLOSURE_NO_DEPS = true; end puts "Saved to #{outfile}" end + +require 'rake/testtask' + +Rake::TestTask.new(:test) do |t| + t.libs << 'lib' + t.libs << 'test' + t.pattern = 'test/**/*_test.rb' + t.verbose = false +end From ae69318ad542155c5ba70b5ecf4cb68b3b9a0cbc Mon Sep 17 00:00:00 2001 From: Vadim Senderovich Date: Thu, 11 Oct 2012 10:18:05 +0200 Subject: [PATCH 2/3] updated libphonenumber.js from google source --- support/libphonenumber.js | 5406 +++++++++++++++++++++++-------------- 1 file changed, 3390 insertions(+), 2016 deletions(-) diff --git a/support/libphonenumber.js b/support/libphonenumber.js index 890925a..1611456 100644 --- a/support/libphonenumber.js +++ b/support/libphonenumber.js @@ -24,6 +24,8 @@ var CLOSURE_NO_DEPS = true; * global CLOSURE_NO_DEPS is set to true. This allows projects to * include their own deps file(s) from different locations. * + * + * @provideGoog */ @@ -271,7 +273,7 @@ goog.addDependency = function(relPath, provides, requires) { -// NOTE(user): The debug DOM loader was included in base.js as an orignal +// NOTE(nnaze): The debug DOM loader was included in base.js as an orignal // way to do "debug-mode" development. The dependency system can sometimes // be confusing, as can the debug DOM loader's asyncronous nature. // @@ -314,10 +316,10 @@ goog.ENABLE_DEBUG_LOADER = true; goog.require = function(name) { // if the object already exists we do not need do do anything - // TODO(user): If we start to support require based on file name this has + // TODO(arv): If we start to support require based on file name this has // to change - // TODO(user): If we allow goog.foo.* this has to change - // TODO(user): If we implement dynamic load after page load we should probably + // TODO(arv): If we allow goog.foo.* this has to change + // TODO(arv): If we implement dynamic load after page load we should probably // not remove this code for the compiled output if (!COMPILED) { if (goog.isProvided_(name)) { @@ -389,12 +391,14 @@ goog.nullFunction = function() {}; /** * The identity function. Returns its first argument. * - * @param {...*} var_args The arguments of the function. - * @return {*} The first argument. + * @param {*=} opt_returnValue The single value that will be returned. + * @param {...*} var_args Optional trailing arguments. These are ignored. + * @return {?} The first argument. We can't know the type -- just pass it along + * without type. * @deprecated Use goog.functions.identity instead. */ -goog.identityFunction = function(var_args) { - return arguments[0]; +goog.identityFunction = function(opt_returnValue, var_args) { + return opt_returnValue; }; @@ -427,11 +431,28 @@ goog.abstractMethod = function() { */ goog.addSingletonGetter = function(ctor) { ctor.getInstance = function() { - return ctor.instance_ || (ctor.instance_ = new ctor()); + if (ctor.instance_) { + return ctor.instance_; + } + if (goog.DEBUG) { + // NOTE: JSCompiler can't optimize away Array#push. + goog.instantiatedSingletons_[goog.instantiatedSingletons_.length] = ctor; + } + return ctor.instance_ = new ctor; }; }; +/** + * All singleton classes that have been instantiated, for testing. Don't read + * it directly, use the {@code goog.testing.singleton} module. The compiler + * removes this variable if unused. + * @type {!Array.} + * @private + */ +goog.instantiatedSingletons_ = []; + + if (!COMPILED && goog.ENABLE_DEBUG_LOADER) { /** * Object used to keep track of urls that have already been added. This @@ -524,6 +545,23 @@ if (!COMPILED && goog.ENABLE_DEBUG_LOADER) { goog.writeScriptTag_ = function(src) { if (goog.inHtmlDocument_()) { var doc = goog.global.document; + + // If the user tries to require a new symbol after document load, + // something has gone terribly wrong. Doing a document.write would + // wipe out the page. + if (doc.readyState == 'complete') { + // Certain test frameworks load base.js multiple times, which tries + // to write deps.js each time. If that happens, just fail silently. + // These frameworks wipe the page between each load of base.js, so this + // is OK. + var isDeps = /\bdeps.js$/.test(src); + if (isDeps) { + return false; + } else { + throw Error('Cannot write "' + src + '" after document load'); + } + } + doc.write( '