Commit 5cfa7fb5 authored by Michael Achenbach's avatar Michael Achenbach Committed by Commit Bot

[foozzie] Use simpler date mock

The previous method was too brittle as applying a variable number of arguments to Date can be manipulated in too many ways, e.g. concat and apply semantics.

The new method shoud suffice for most cases.

BUG=chromium:698305
NOTRY=true
TBR=yangguo@chromium.org,mstarzinger@chromium.org

Change-Id: If6baf6ca8f1534c41ab8c50a5c507df89fbf0d16
Reviewed-on: https://chromium-review.googlesource.com/449653Reviewed-by: 's avatarMichael Achenbach <machenbach@chromium.org>
Reviewed-by: 's avatarMichael Starzinger <mstarzinger@chromium.org>
Commit-Queue: Michael Achenbach <machenbach@chromium.org>
Cr-Commit-Position: refs/heads/master@{#43601}
parent 49ff8c1d
......@@ -31,13 +31,24 @@ var __PrettyPrint = function __PrettyPrint(msg) { print(msg); };
return mockDate
}
var origConcat = Array.prototype.concat
var origDate = Date;
var constructDate = function(args) {
if (args.length > 0) {
var result = new (
Function.prototype.bind.apply(
origDate, origConcat.apply([null], args)));
if (args.length == 1) {
var result = new origDate(args[0]);
} else if (args.length == 2) {
var result = new origDate(args[0], args[1]);
} else if (args.length == 3) {
var result = new origDate(args[0], args[1], args[2]);
} else if (args.length == 4) {
var result = new origDate(args[0], args[1], args[2], args[3]);
} else if (args.length == 5) {
var result = new origDate(args[0], args[1], args[2], args[3], args[4]);
} else if (args.length == 6) {
var result = new origDate(
args[0], args[1], args[2], args[3], args[4], args[5]);
} else if (args.length >= 7) {
var result = new origDate(
args[0], args[1], args[2], args[3], args[4], args[5], args[6]);
} else {
var result = new origDate(mockDateNow());
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment