Skip to content

Commit

Permalink
Add branding and prop-desc tests for Date.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ms2ger authored and ryzokuken committed Aug 24, 2020
1 parent f7ece3a commit dd6b1f7
Show file tree
Hide file tree
Showing 43 changed files with 692 additions and 0 deletions.
20 changes: 20 additions & 0 deletions polyfill/test/Date/prototype/day/branding.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Copyright (C) 2020 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: sec-get-temporal.date.prototype.day
---*/

const day = Object.getOwnPropertyDescriptor(Temporal.Date.prototype, "day").get;

assert.sameValue(typeof day, "function");

assert.throws(TypeError, () => day.call(undefined), "undefined");
assert.throws(TypeError, () => day.call(null), "null");
assert.throws(TypeError, () => day.call(true), "true");
assert.throws(TypeError, () => day.call(""), "empty string");
assert.throws(TypeError, () => day.call(Symbol()), "symbol");
assert.throws(TypeError, () => day.call(1), "1");
assert.throws(TypeError, () => day.call({}), "plain object");
assert.throws(TypeError, () => day.call(Temporal.Date), "Temporal.Date");
assert.throws(TypeError, () => day.call(Temporal.Date.prototype), "Temporal.Date.prototype");
12 changes: 12 additions & 0 deletions polyfill/test/Date/prototype/day/prop-desc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// Copyright (C) 2020 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: sec-get-temporal.date.prototype.day
---*/

const descriptor = Object.getOwnPropertyDescriptor(Temporal.Date.prototype, "day");
assert.sameValue(typeof descriptor.get, "function");
assert.sameValue(descriptor.set, undefined);
assert.sameValue(descriptor.enumerable, false);
assert.sameValue(descriptor.configurable, true);
20 changes: 20 additions & 0 deletions polyfill/test/Date/prototype/dayOfWeek/branding.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Copyright (C) 2020 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: sec-get-temporal.date.prototype.dayofweek
---*/

const dayOfWeek = Object.getOwnPropertyDescriptor(Temporal.Date.prototype, "dayOfWeek").get;

assert.sameValue(typeof dayOfWeek, "function");

assert.throws(TypeError, () => dayOfWeek.call(undefined), "undefined");
assert.throws(TypeError, () => dayOfWeek.call(null), "null");
assert.throws(TypeError, () => dayOfWeek.call(true), "true");
assert.throws(TypeError, () => dayOfWeek.call(""), "empty string");
assert.throws(TypeError, () => dayOfWeek.call(Symbol()), "symbol");
assert.throws(TypeError, () => dayOfWeek.call(1), "1");
assert.throws(TypeError, () => dayOfWeek.call({}), "plain object");
assert.throws(TypeError, () => dayOfWeek.call(Temporal.Date), "Temporal.Date");
assert.throws(TypeError, () => dayOfWeek.call(Temporal.Date.prototype), "Temporal.Date.prototype");
12 changes: 12 additions & 0 deletions polyfill/test/Date/prototype/dayOfWeek/prop-desc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// Copyright (C) 2020 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: sec-get-temporal.date.prototype.dayofweek
---*/

const descriptor = Object.getOwnPropertyDescriptor(Temporal.Date.prototype, "dayOfWeek");
assert.sameValue(typeof descriptor.get, "function");
assert.sameValue(descriptor.set, undefined);
assert.sameValue(descriptor.enumerable, false);
assert.sameValue(descriptor.configurable, true);
20 changes: 20 additions & 0 deletions polyfill/test/Date/prototype/dayOfYear/branding.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Copyright (C) 2020 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: sec-get-temporal.date.prototype.dayofyear
---*/

const dayOfYear = Object.getOwnPropertyDescriptor(Temporal.Date.prototype, "dayOfYear").get;

assert.sameValue(typeof dayOfYear, "function");

assert.throws(TypeError, () => dayOfYear.call(undefined), "undefined");
assert.throws(TypeError, () => dayOfYear.call(null), "null");
assert.throws(TypeError, () => dayOfYear.call(true), "true");
assert.throws(TypeError, () => dayOfYear.call(""), "empty string");
assert.throws(TypeError, () => dayOfYear.call(Symbol()), "symbol");
assert.throws(TypeError, () => dayOfYear.call(1), "1");
assert.throws(TypeError, () => dayOfYear.call({}), "plain object");
assert.throws(TypeError, () => dayOfYear.call(Temporal.Date), "Temporal.Date");
assert.throws(TypeError, () => dayOfYear.call(Temporal.Date.prototype), "Temporal.Date.prototype");
12 changes: 12 additions & 0 deletions polyfill/test/Date/prototype/dayOfYear/prop-desc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// Copyright (C) 2020 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: sec-get-temporal.date.prototype.dayofyear
---*/

const descriptor = Object.getOwnPropertyDescriptor(Temporal.Date.prototype, "dayOfYear");
assert.sameValue(typeof descriptor.get, "function");
assert.sameValue(descriptor.set, undefined);
assert.sameValue(descriptor.enumerable, false);
assert.sameValue(descriptor.configurable, true);
20 changes: 20 additions & 0 deletions polyfill/test/Date/prototype/daysInMonth/branding.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Copyright (C) 2020 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: sec-get-temporal.date.prototype.daysinmonth
---*/

const daysInMonth = Object.getOwnPropertyDescriptor(Temporal.Date.prototype, "daysInMonth").get;

assert.sameValue(typeof daysInMonth, "function");

assert.throws(TypeError, () => daysInMonth.call(undefined), "undefined");
assert.throws(TypeError, () => daysInMonth.call(null), "null");
assert.throws(TypeError, () => daysInMonth.call(true), "true");
assert.throws(TypeError, () => daysInMonth.call(""), "empty string");
assert.throws(TypeError, () => daysInMonth.call(Symbol()), "symbol");
assert.throws(TypeError, () => daysInMonth.call(1), "1");
assert.throws(TypeError, () => daysInMonth.call({}), "plain object");
assert.throws(TypeError, () => daysInMonth.call(Temporal.Date), "Temporal.Date");
assert.throws(TypeError, () => daysInMonth.call(Temporal.Date.prototype), "Temporal.Date.prototype");
12 changes: 12 additions & 0 deletions polyfill/test/Date/prototype/daysInMonth/prop-desc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// Copyright (C) 2020 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: sec-get-temporal.date.prototype.daysinmonth
---*/

const descriptor = Object.getOwnPropertyDescriptor(Temporal.Date.prototype, "daysInMonth");
assert.sameValue(typeof descriptor.get, "function");
assert.sameValue(descriptor.set, undefined);
assert.sameValue(descriptor.enumerable, false);
assert.sameValue(descriptor.configurable, true);
20 changes: 20 additions & 0 deletions polyfill/test/Date/prototype/daysInYear/branding.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Copyright (C) 2020 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: sec-get-temporal.date.prototype.daysinyear
---*/

const daysInYear = Object.getOwnPropertyDescriptor(Temporal.Date.prototype, "daysInYear").get;

assert.sameValue(typeof daysInYear, "function");

assert.throws(TypeError, () => daysInYear.call(undefined), "undefined");
assert.throws(TypeError, () => daysInYear.call(null), "null");
assert.throws(TypeError, () => daysInYear.call(true), "true");
assert.throws(TypeError, () => daysInYear.call(""), "empty string");
assert.throws(TypeError, () => daysInYear.call(Symbol()), "symbol");
assert.throws(TypeError, () => daysInYear.call(1), "1");
assert.throws(TypeError, () => daysInYear.call({}), "plain object");
assert.throws(TypeError, () => daysInYear.call(Temporal.Date), "Temporal.Date");
assert.throws(TypeError, () => daysInYear.call(Temporal.Date.prototype), "Temporal.Date.prototype");
12 changes: 12 additions & 0 deletions polyfill/test/Date/prototype/daysInYear/prop-desc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// Copyright (C) 2020 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: sec-get-temporal.date.prototype.daysinyear
---*/

const descriptor = Object.getOwnPropertyDescriptor(Temporal.Date.prototype, "daysInYear");
assert.sameValue(typeof descriptor.get, "function");
assert.sameValue(descriptor.set, undefined);
assert.sameValue(descriptor.enumerable, false);
assert.sameValue(descriptor.configurable, true);
20 changes: 20 additions & 0 deletions polyfill/test/Date/prototype/difference/branding.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Copyright (C) 2020 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: sec-temporal.date.prototype.difference
---*/

const difference = Temporal.Date.prototype.difference;

assert.sameValue(typeof difference, "function");

assert.throws(TypeError, () => difference.call(undefined), "undefined");
assert.throws(TypeError, () => difference.call(null), "null");
assert.throws(TypeError, () => difference.call(true), "true");
assert.throws(TypeError, () => difference.call(""), "empty string");
assert.throws(TypeError, () => difference.call(Symbol()), "symbol");
assert.throws(TypeError, () => difference.call(1), "1");
assert.throws(TypeError, () => difference.call({}), "plain object");
assert.throws(TypeError, () => difference.call(Temporal.Date), "Temporal.Date");
assert.throws(TypeError, () => difference.call(Temporal.Date.prototype), "Temporal.Date.prototype");
19 changes: 19 additions & 0 deletions polyfill/test/Date/prototype/difference/prop-desc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// Copyright (C) 2020 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: sec-temporal.date.prototype.difference
includes: [propertyHelper.js]
---*/

assert.sameValue(
typeof Temporal.Date.prototype.difference,
"function",
"`typeof Date.prototype.difference` is `function`"
);

verifyProperty(Temporal.Date.prototype, "difference", {
writable: true,
enumerable: false,
configurable: true,
});
1 change: 1 addition & 0 deletions polyfill/test/Date/prototype/equals/prop-desc.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: sec-temporal.date.prototype.equals
includes: [propertyHelper.js]
---*/

Expand Down
7 changes: 7 additions & 0 deletions polyfill/test/Date/prototype/getFields/branding.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
// Copyright (C) 2020 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: sec-temporal.date.prototype.getfields
---*/

const getFields = Temporal.Date.prototype.getFields;

assert.sameValue(typeof getFields, "function");
Expand All @@ -11,3 +15,6 @@ assert.throws(TypeError, () => getFields.call(true), "true");
assert.throws(TypeError, () => getFields.call(""), "empty string");
assert.throws(TypeError, () => getFields.call(Symbol()), "symbol");
assert.throws(TypeError, () => getFields.call(1), "1");
assert.throws(TypeError, () => getFields.call({}), "plain object");
assert.throws(TypeError, () => getFields.call(Temporal.Date), "Temporal.Date");
assert.throws(TypeError, () => getFields.call(Temporal.Date.prototype), "Temporal.Date.prototype");
1 change: 1 addition & 0 deletions polyfill/test/Date/prototype/getFields/prop-desc.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: sec-temporal.date.prototype.getfields
includes: [propertyHelper.js]
---*/

Expand Down
4 changes: 4 additions & 0 deletions polyfill/test/Date/prototype/getISOCalendarFields/branding.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
// Copyright (C) 2020 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: sec-temporal.date.prototype.getisocalendarfields
---*/

const getISOCalendarFields = Temporal.Date.prototype.getISOCalendarFields;

assert.sameValue(typeof getISOCalendarFields, "function");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: sec-temporal.date.prototype.getisocalendarfields
includes: [propertyHelper.js]
---*/

Expand Down
20 changes: 20 additions & 0 deletions polyfill/test/Date/prototype/isLeapYear/branding.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Copyright (C) 2020 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: sec-get-temporal.date.prototype.isleapyear
---*/

const isLeapYear = Object.getOwnPropertyDescriptor(Temporal.Date.prototype, "isLeapYear").get;

assert.sameValue(typeof isLeapYear, "function");

assert.throws(TypeError, () => isLeapYear.call(undefined), "undefined");
assert.throws(TypeError, () => isLeapYear.call(null), "null");
assert.throws(TypeError, () => isLeapYear.call(true), "true");
assert.throws(TypeError, () => isLeapYear.call(""), "empty string");
assert.throws(TypeError, () => isLeapYear.call(Symbol()), "symbol");
assert.throws(TypeError, () => isLeapYear.call(1), "1");
assert.throws(TypeError, () => isLeapYear.call({}), "plain object");
assert.throws(TypeError, () => isLeapYear.call(Temporal.Date), "Temporal.Date");
assert.throws(TypeError, () => isLeapYear.call(Temporal.Date.prototype), "Temporal.Date.prototype");
12 changes: 12 additions & 0 deletions polyfill/test/Date/prototype/isLeapYear/prop-desc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// Copyright (C) 2020 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: sec-get-temporal.date.prototype.isleapyear
---*/

const descriptor = Object.getOwnPropertyDescriptor(Temporal.Date.prototype, "isLeapYear");
assert.sameValue(typeof descriptor.get, "function");
assert.sameValue(descriptor.set, undefined);
assert.sameValue(descriptor.enumerable, false);
assert.sameValue(descriptor.configurable, true);
20 changes: 20 additions & 0 deletions polyfill/test/Date/prototype/minus/branding.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Copyright (C) 2020 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: sec-temporal.date.prototype.minus
---*/

const minus = Temporal.Date.prototype.minus;

assert.sameValue(typeof minus, "function");

assert.throws(TypeError, () => minus.call(undefined), "undefined");
assert.throws(TypeError, () => minus.call(null), "null");
assert.throws(TypeError, () => minus.call(true), "true");
assert.throws(TypeError, () => minus.call(""), "empty string");
assert.throws(TypeError, () => minus.call(Symbol()), "symbol");
assert.throws(TypeError, () => minus.call(1), "1");
assert.throws(TypeError, () => minus.call({}), "plain object");
assert.throws(TypeError, () => minus.call(Temporal.Date), "Temporal.Date");
assert.throws(TypeError, () => minus.call(Temporal.Date.prototype), "Temporal.Date.prototype");
19 changes: 19 additions & 0 deletions polyfill/test/Date/prototype/minus/prop-desc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// Copyright (C) 2020 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: sec-temporal.date.prototype.minus
includes: [propertyHelper.js]
---*/

assert.sameValue(
typeof Temporal.Date.prototype.minus,
"function",
"`typeof Date.prototype.minus` is `function`"
);

verifyProperty(Temporal.Date.prototype, "minus", {
writable: true,
enumerable: false,
configurable: true,
});
20 changes: 20 additions & 0 deletions polyfill/test/Date/prototype/month/branding.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Copyright (C) 2020 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: sec-get-temporal.date.prototype.month
---*/

const month = Object.getOwnPropertyDescriptor(Temporal.Date.prototype, "month").get;

assert.sameValue(typeof month, "function");

assert.throws(TypeError, () => month.call(undefined), "undefined");
assert.throws(TypeError, () => month.call(null), "null");
assert.throws(TypeError, () => month.call(true), "true");
assert.throws(TypeError, () => month.call(""), "empty string");
assert.throws(TypeError, () => month.call(Symbol()), "symbol");
assert.throws(TypeError, () => month.call(1), "1");
assert.throws(TypeError, () => month.call({}), "plain object");
assert.throws(TypeError, () => month.call(Temporal.Date), "Temporal.Date");
assert.throws(TypeError, () => month.call(Temporal.Date.prototype), "Temporal.Date.prototype");
12 changes: 12 additions & 0 deletions polyfill/test/Date/prototype/month/prop-desc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// Copyright (C) 2020 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: sec-get-temporal.date.prototype.month
---*/

const descriptor = Object.getOwnPropertyDescriptor(Temporal.Date.prototype, "month");
assert.sameValue(typeof descriptor.get, "function");
assert.sameValue(descriptor.set, undefined);
assert.sameValue(descriptor.enumerable, false);
assert.sameValue(descriptor.configurable, true);
20 changes: 20 additions & 0 deletions polyfill/test/Date/prototype/plus/branding.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// Copyright (C) 2020 Igalia, S.L. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.

/*---
esid: sec-temporal.date.prototype.plus
---*/

const plus = Temporal.Date.prototype.plus;

assert.sameValue(typeof plus, "function");

assert.throws(TypeError, () => plus.call(undefined), "undefined");
assert.throws(TypeError, () => plus.call(null), "null");
assert.throws(TypeError, () => plus.call(true), "true");
assert.throws(TypeError, () => plus.call(""), "empty string");
assert.throws(TypeError, () => plus.call(Symbol()), "symbol");
assert.throws(TypeError, () => plus.call(1), "1");
assert.throws(TypeError, () => plus.call({}), "plain object");
assert.throws(TypeError, () => plus.call(Temporal.Date), "Temporal.Date");
assert.throws(TypeError, () => plus.call(Temporal.Date.prototype), "Temporal.Date.prototype");
Loading

0 comments on commit dd6b1f7

Please sign in to comment.