From 2aa4a82499d4becd2284cdb482213d541b8804dd Mon Sep 17 00:00:00 2001
From: Daniel Baumann <daniel.baumann@progress-linux.org>
Date: Sun, 28 Apr 2024 16:29:10 +0200
Subject: Adding upstream version 86.0.1.

Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
---
 .../test262/built-ins/Math/random/S15.8.2.14_A1.js | 30 +++++++++++++++++++++
 .../tests/test262/built-ins/Math/random/browser.js |  0
 .../tests/test262/built-ins/Math/random/length.js  | 31 ++++++++++++++++++++++
 js/src/tests/test262/built-ins/Math/random/name.js | 28 +++++++++++++++++++
 .../built-ins/Math/random/not-a-constructor.js     | 31 ++++++++++++++++++++++
 .../test262/built-ins/Math/random/prop-desc.js     | 19 +++++++++++++
 .../tests/test262/built-ins/Math/random/shell.js   | 19 +++++++++++++
 7 files changed, 158 insertions(+)
 create mode 100644 js/src/tests/test262/built-ins/Math/random/S15.8.2.14_A1.js
 create mode 100644 js/src/tests/test262/built-ins/Math/random/browser.js
 create mode 100644 js/src/tests/test262/built-ins/Math/random/length.js
 create mode 100644 js/src/tests/test262/built-ins/Math/random/name.js
 create mode 100644 js/src/tests/test262/built-ins/Math/random/not-a-constructor.js
 create mode 100644 js/src/tests/test262/built-ins/Math/random/prop-desc.js
 create mode 100644 js/src/tests/test262/built-ins/Math/random/shell.js

(limited to 'js/src/tests/test262/built-ins/Math/random')

diff --git a/js/src/tests/test262/built-ins/Math/random/S15.8.2.14_A1.js b/js/src/tests/test262/built-ins/Math/random/S15.8.2.14_A1.js
new file mode 100644
index 0000000000..630fd96373
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Math/random/S15.8.2.14_A1.js
@@ -0,0 +1,30 @@
+// Copyright 2009 the Sputnik authors.  All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+info: |
+    Math.random() returns a number value with positive sign, greater than or
+    equal to 0 but less than 1
+es5id: 15.8.2.14_A1
+description: >
+    Checking if Math.random() is a number between 0 and 1, calling
+    Math.random() 100 times
+---*/
+
+// CHECK#1
+for (var i = 0; i < 100; i++)
+{
+  var val = Math.random();
+
+  assert.sameValue(
+    typeof val, 'number', 'should not produce a non-numeric value: ' + val
+  );
+  assert.notSameValue(val, NaN, 'should not produce NaN');
+
+  if (val < 0 || val >= 1)
+  {
+    $ERROR("#1: Math.random() = " + val);
+  }
+}
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Math/random/browser.js b/js/src/tests/test262/built-ins/Math/random/browser.js
new file mode 100644
index 0000000000..e69de29bb2
diff --git a/js/src/tests/test262/built-ins/Math/random/length.js b/js/src/tests/test262/built-ins/Math/random/length.js
new file mode 100644
index 0000000000..21c8e5304f
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Math/random/length.js
@@ -0,0 +1,31 @@
+// Copyright (C) 2015 André Bargull. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+es6id: 20.2.2.27
+description: >
+  Math.random.length is 0.
+info: |
+  Math.random ( )
+
+  17 ECMAScript Standard Built-in Objects:
+    Every built-in Function object, including constructors, has a length
+    property whose value is an integer. Unless otherwise specified, this
+    value is equal to the largest number of named arguments shown in the
+    subclause headings for the function description, including optional
+    parameters. However, rest parameters shown using the form “...name”
+    are not included in the default argument count.
+
+    Unless otherwise specified, the length property of a built-in Function
+    object has the attributes { [[Writable]]: false, [[Enumerable]]: false,
+    [[Configurable]]: true }.
+includes: [propertyHelper.js]
+---*/
+
+assert.sameValue(Math.random.length, 0);
+
+verifyNotEnumerable(Math.random, "length");
+verifyNotWritable(Math.random, "length");
+verifyConfigurable(Math.random, "length");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Math/random/name.js b/js/src/tests/test262/built-ins/Math/random/name.js
new file mode 100644
index 0000000000..a6f983e5bc
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Math/random/name.js
@@ -0,0 +1,28 @@
+// Copyright (C) 2015 André Bargull. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+es6id: 20.2.2.27
+description: >
+  Math.random.name is "random".
+info: |
+  Math.random ( )
+
+  17 ECMAScript Standard Built-in Objects:
+    Every built-in Function object, including constructors, that is not
+    identified as an anonymous function has a name property whose value
+    is a String.
+
+    Unless otherwise specified, the name property of a built-in Function
+    object, if it exists, has the attributes { [[Writable]]: false,
+    [[Enumerable]]: false, [[Configurable]]: true }.
+includes: [propertyHelper.js]
+---*/
+
+assert.sameValue(Math.random.name, "random");
+
+verifyNotEnumerable(Math.random, "name");
+verifyNotWritable(Math.random, "name");
+verifyConfigurable(Math.random, "name");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Math/random/not-a-constructor.js b/js/src/tests/test262/built-ins/Math/random/not-a-constructor.js
new file mode 100644
index 0000000000..8160a93744
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Math/random/not-a-constructor.js
@@ -0,0 +1,31 @@
+// Copyright (C) 2020 Rick Waldron. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-ecmascript-standard-built-in-objects
+description: >
+  Math.random does not implement [[Construct]], is not new-able
+info: |
+  ECMAScript Function Objects
+
+  Built-in function objects that are not identified as constructors do not
+  implement the [[Construct]] internal method unless otherwise specified in
+  the description of a particular function.
+
+  sec-evaluatenew
+
+  ...
+  7. If IsConstructor(constructor) is false, throw a TypeError exception.
+  ...
+includes: [isConstructor.js]
+features: [Reflect.construct, arrow-function]
+---*/
+
+assert.sameValue(isConstructor(Math.random), false, 'isConstructor(Math.random) must return false');
+
+assert.throws(TypeError, () => {
+  new Math.random();
+}, '`new Math.random()` throws TypeError');
+
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Math/random/prop-desc.js b/js/src/tests/test262/built-ins/Math/random/prop-desc.js
new file mode 100644
index 0000000000..c78765c574
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Math/random/prop-desc.js
@@ -0,0 +1,19 @@
+// Copyright (C) 2017 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+esid: sec-math.random
+description: >
+  "random" property of Math
+info: |
+  Section 17: Every other data property described in clauses 18 through 26
+  and in Annex B.2 has the attributes { [[Writable]]: true,
+  [[Enumerable]]: false, [[Configurable]]: true } unless otherwise specified.
+includes: [propertyHelper.js]
+---*/
+
+verifyNotEnumerable(Math, "random");
+verifyWritable(Math, "random");
+verifyConfigurable(Math, "random");
+
+reportCompare(0, 0);
diff --git a/js/src/tests/test262/built-ins/Math/random/shell.js b/js/src/tests/test262/built-ins/Math/random/shell.js
new file mode 100644
index 0000000000..54371b7789
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Math/random/shell.js
@@ -0,0 +1,19 @@
+// GENERATED, DO NOT EDIT
+// file: isConstructor.js
+// Copyright (C) 2017 André Bargull. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: |
+    Test if a given function is a constructor function.
+defines: [isConstructor]
+---*/
+
+function isConstructor(f) {
+    try {
+        Reflect.construct(function(){}, [], f);
+    } catch (e) {
+        return false;
+    }
+    return true;
+}
-- 
cgit v1.2.3