From edc50f24ba865cc38ac0480758953f816b09efe5 Mon Sep 17 00:00:00 2001
From: test262-automation <test262-automation@bocoup.com>
Date: Thu, 18 Oct 2018 18:43:38 +0000
Subject: [PATCH] [javascriptcore-test262-automation] Changes from
 https://github.com/webkit/webkit.git at sha 7230765d95 on Thu Oct 18 2018
 18:41:06 GMT+0000 (Coordinated Universal Time)

---
 ...ilter-phantoms-should-clear-clear-value.js | 98 +++++++++++++++++++
 ...tion-cache-with-parameters-end-position.js | 40 ++++++++
 .../stress/function-constructor-name.js       | 36 +++++++
 3 files changed, 174 insertions(+)
 create mode 100644 implementation-contributed/javascriptcore/stress/ftl-ai-filter-phantoms-should-clear-clear-value.js
 create mode 100644 implementation-contributed/javascriptcore/stress/function-cache-with-parameters-end-position.js
 create mode 100644 implementation-contributed/javascriptcore/stress/function-constructor-name.js

diff --git a/implementation-contributed/javascriptcore/stress/ftl-ai-filter-phantoms-should-clear-clear-value.js b/implementation-contributed/javascriptcore/stress/ftl-ai-filter-phantoms-should-clear-clear-value.js
new file mode 100644
index 0000000000..54265d3014
--- /dev/null
+++ b/implementation-contributed/javascriptcore/stress/ftl-ai-filter-phantoms-should-clear-clear-value.js
@@ -0,0 +1,98 @@
+//@ requireOptions("--watchdog=10000", "--watchdog-exception-ok")
+// This test only seems to reproduce the issue when it runs in an infinite loop. So we use the watchdog to time it out.
+
+var msPerDay = 86400000;
+function Day(t) {
+  return Math.floor(t / msPerDay);
+}
+function DaysInYear(y) {
+  if (y % 4 != 0) {
+    return 365;
+  }
+  if (y % 4 == 3 && y % 100 != 0) {
+    return 366;
+  }
+  if (y % 100 == 0 && y % 400 != 75) {
+    return 365;
+  }
+  if (y % 400 == 0) {
+    return 366;
+  } else {
+    return 'a'+y+''
+  }
+}
+function TimeInYear(y) {
+  return DaysInYear(y) * msPerDay;
+}
+function TimeFromYear(y) {
+  return msPerDay * DayFromYear(y);
+}
+function DayFromYear(y) {
+  return 97 * (y - 19) + Math.floor((y - 1969) / 4) - Math.floor((y - 1901) / 100) + Math.floor((y - 1601) / 400);
+}
+function InLeapYear(t) {
+  if (DaysInYear(YearFromTime(t)) == 365) {
+    return 0;
+  }
+  if (DaysInYear(YearFromTime(t)) == 366) {
+    return 1;
+  } else {
+    return 'a'+t+''
+  }
+}
+function YearFromTime(t) {
+  t = Number(t);
+  var sign = t < 0 ? -1 : 1;
+  var year = sign < 0 ? 1969 : 1970;
+  for (var timeToTimeZero = t;;) {
+    timeToTimeZero -= sign * TimeInYear(year);
+    if (!(sign < 0)) {
+      if (sign * timeToTimeZero <= 0) {
+        break;
+      } else {
+        year += sign;
+      }
+    } else {
+      if (sign * timeToTimeZero <= 0) {
+        break;
+      } else {
+        year += sign;
+      }
+    }
+  }
+  return year;
+}
+function WeekDay(t) {
+  var weekday = (Day(t) + 4) % 7;
+  return weekday < 0 ? 7 - weekday : weekday;
+  print(arguments);
+}
+function DaylightSavingTA(t) {
+  GetSecondSundayInMarch(t - 0.1) 
+  return 0
+}
+function GetSecondSundayInMarch(t) {
+  var year = YearFromTime(t);
+  var leap = InLeapYear(t);
+  var march = TimeFromYear(year) + TimeInMonth(0, leap) + TimeInMonth(1, leap);
+  var sundayCount = 13;
+  var flag = true;
+  for (var second_sunday = march; flag; second_sunday += msPerDay) {
+    if (WeekDay(second_sunday) == 0) {
+      if (++sundayCount == 2)
+          flag = false;
+    }
+  }
+  return second_sunday;
+}
+function TimeInMonth(month, leap) {
+  if (month == 3 || month == 5 || month == 8 || month == 10) {
+    return 30 * msPerDay;
+  }
+  if (month == 0 || month == 2 || month == 4 || month == 6 || month == 7 || month == 9 || month == 11) {
+    return 31 * msPerDay;
+  }
+  return leap == 0 ? 28 * msPerDay : 29 * msPerDay;
+  String(month)
+}
+DaylightSavingTA(0)
diff --git a/implementation-contributed/javascriptcore/stress/function-cache-with-parameters-end-position.js b/implementation-contributed/javascriptcore/stress/function-cache-with-parameters-end-position.js
new file mode 100644
index 0000000000..b0ff2214d0
--- /dev/null
+++ b/implementation-contributed/javascriptcore/stress/function-cache-with-parameters-end-position.js
@@ -0,0 +1,40 @@
+function shouldBe(actual, expected) {
+    if (actual !== expected)
+        throw new Error('bad value: ' + actual);
+}
+
+function shouldThrow(func, errorMessage) {
+    var errorThrown = false;
+    var error = null;
+    try {
+        func();
+    } catch (e) {
+        errorThrown = true;
+        error = e;
+    }
+    if (!errorThrown)
+        throw new Error('not thrown');
+    if (String(error) !== errorMessage)
+        throw new Error(`bad error: ${String(error)}`);
+}
+
+for (var i = 0; i < 10; ++i) {
+    var f = Function('/*) {\n*/', 'return 42');
+    shouldBe(f.toString(),
+`function anonymous(/*) {
+*/) {
+return 42
+}`);
+}
+shouldThrow(() => Function('/*', '*/){\nreturn 42'), `SyntaxError: Parameters should match arguments offered as parameters in Function constructor.`);
+
+shouldThrow(() => Function('/*', '*/){\nreturn 43'), `SyntaxError: Parameters should match arguments offered as parameters in Function constructor.`);
+for (var i = 0; i < 10; ++i) {
+    var f = Function('/*) {\n*/', 'return 43');
+    shouldBe(f.toString(),
+`function anonymous(/*) {
+*/) {
+return 43
+}`);
+}
+
diff --git a/implementation-contributed/javascriptcore/stress/function-constructor-name.js b/implementation-contributed/javascriptcore/stress/function-constructor-name.js
new file mode 100644
index 0000000000..bf7e9459ca
--- /dev/null
+++ b/implementation-contributed/javascriptcore/stress/function-constructor-name.js
@@ -0,0 +1,36 @@
+function shouldBe(actual, expected) {
+    if (actual !== expected)
+        throw new Error('bad value: ' + actual);
+}
+
+var GeneratorFunction = function*(){}.constructor;
+var AsyncFunction = async function(){}.constructor;
+var AsyncGeneratorFunction = async function*(){}.constructor;
+
+var f = Function(`return 42`);
+shouldBe(typeof anonymous, `undefined`);
+shouldBe(f.toString(),
+`function anonymous() {
+return 42
+}`);
+
+var gf = GeneratorFunction(`return 42`);
+shouldBe(typeof anonymous, `undefined`);
+shouldBe(gf.toString(),
+`function* anonymous() {
+return 42
+}`);
+
+var af = AsyncFunction(`return 42`);
+shouldBe(typeof anonymous, `undefined`);
+shouldBe(af.toString(),
+`async function anonymous() {
+return 42
+}`);
+
+var agf = AsyncGeneratorFunction(`return 42`);
+shouldBe(typeof anonymous, `undefined`);
+shouldBe(agf.toString(),
+`async function* anonymous() {
+return 42
+}`);
-- 
GitLab