summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/basic/date-late-weekday-warning.js
blob: ca6730e56cf25b98d6183940428edc53c0760967 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
/**
 * Test deprecation warning for late weekday in Date.parse
 */

function testWarn(date) {
  const g = newGlobal();
  g.eval(`Date.parse("${date}")`);
  const warning = getLastWarning();
  assertEq(warning !== null, true, `warning should be caught for ${date}`);
  assertEq(warning.name, "Warning", warning.name);

  clearLastWarning();

  g.eval(`Date.parse("${date}")`);
  assertEq(getLastWarning(), null, "warning should not be caught for 2nd ocurrence");
}

function testNoWarn(date) {
  Date.parse(date);
  assertEq(getLastWarning(), null, `warning should not be caught for ${date}`);
}

enableLastWarning();

testWarn("Sep 26 1995 Tues");
testWarn("Sep 26 Tues 1995");
testWarn("Sep 26 Tues 1995 Tues");
testWarn("Sep 26 1995 10:Tues:00");

testNoWarn("Sep 26 1995");
testNoWarn("Tues Sep 26 1995");
testNoWarn("Sep Tues 26 1995");

disableLastWarning();