Quellcodebibliothek Statistik Leitseite products/Sources/formale Sprachen/C/Firefox/js/src/jit-test/tests/cacheir/   (Firefox Browser Version 136.0.1©)  Datei vom 10.2.2025 mit Größe 4 kB image not shown  

Quelle  date-basic.js

  Sprache: JAVA
 

function testDateGetTime() {
  var timeValues = [
    -1000,
    +1000,
    0,
    NaN,
  ];

  for (var i = 0; i < 250; ++i) {
    var t = timeValues[i & 3];
    var d = new Date(t);
    assertEq(d.getTime(), t);
    assertEq(d.valueOf(), t);
  }
}
testDateGetTime();

var dateValues = [
  // Start of the epoch and start of the year date.
  [19701-114],

  // End of year date.
  [202312-1310],

  // Date near maximum allowed time value (275760 September, 13).
  [2757609-113 - 15],

  // Date near minimum allowed time value (-271821 April, 20).
  [-2718214-120 + 13],

  // Invalid Date.
  [NaN, NaN, NaN, NaN],
];

function testDateGetFullYear() {
  for (var i = 0; i < 250; ++i) {
    var [year, month, date] = dateValues[i % dateValues.length];

    // Create a new Date object with an uninitialized local time cache.
    var d = new Date(year, month, date);

    // First call to getFullYear initializes the cache.
    assertEq(d.getFullYear(), year);

    // Second call to getFullYear uses the cached value.
    assertEq(d.getFullYear(), year);
  }
}
testDateGetFullYear();

function testDateGetMonth() {
  for (var i = 0; i < 250; ++i) {
    var [year, month, date] = dateValues[i % dateValues.length];

    // Create a new Date object with an uninitialized local time cache.
    var d = new Date(year, month, date);

    // First call to getMonth initializes the cache.
    assertEq(d.getMonth(), month);

    // Second call to getMonth uses the cached value.
    assertEq(d.getMonth(), month);
  }
}
testDateGetMonth();

function testDateGetDate() {
  for (var i = 0; i < 250; ++i) {
    var [year, month, date] = dateValues[i % dateValues.length];

    // Create a new Date object with an uninitialized local time cache.
    var d = new Date(year, month, date);

    // First call to getDate initializes the cache.
    assertEq(d.getDate(), date);

    // Second call to getDate uses the cached value.
    assertEq(d.getDate(), date);
  }
}
testDateGetDate();

function testDateGetDay() {
  for (var i = 0; i < 250; ++i) {
    var [year, month, date, day] = dateValues[i % dateValues.length];

    // Create a new Date object with an uninitialized local time cache.
    var d = new Date(year, month, date);

    // First call to getDay initializes the cache.
    assertEq(d.getDay(), day);

    // Second call to getDay uses the cached value.
    assertEq(d.getDay(), day);
  }
}
testDateGetDay();

function testDateGetFullYearMonthDateDay() {
  for (var i = 0; i < 250; ++i) {
    var [year, month, date, day] = dateValues[i % dateValues.length];

    // Create a new Date object with an uninitialized local time cache.
    var d = new Date(year, month, date);

    // Test calling different methods, too.
    assertEq(d.getFullYear(), year);
    assertEq(d.getMonth(), month);
    assertEq(d.getDate(), date);
    assertEq(d.getDay(), day);
  }
}
testDateGetFullYearMonthDateDay();

function testDateGetHours() {
  var timeValues = [
    0,
    12,
    23,
    NaN,
  ];

  for (var i = 0; i < 250; ++i) {
    var t = timeValues[i & 3];

    // Create a new Date object with an uninitialized local time cache.
    var d = new Date(200001, t);

    // First call to getHours initializes the cache.
    assertEq(d.getHours(), t);

    // Second call to getHours uses the cached value.
    assertEq(d.getHours(), t);
  }
}
testDateGetHours();

function testDateGetMinutes() {
  var timeValues = [
    0,
    30,
    59,
    NaN,
  ];

  for (var i = 0; i < 250; ++i) {
    var t = timeValues[i & 3];

    // Create a new Date object with an uninitialized local time cache.
    var d = new Date(2000010, t);

    // First call to getMinutes initializes the cache.
    assertEq(d.getMinutes(), t);

    // Second call to getMinutes uses the cached value.
    assertEq(d.getMinutes(), t);
  }
}
testDateGetMinutes();

function testDateGetSeconds() {
  var timeValues = [
    0,
    30,
    59,
    NaN,
  ];

  for (var i = 0; i < 250; ++i) {
    var t = timeValues[i & 3];

    // Create a new Date object with an uninitialized local time cache.
    var d = new Date(20000100, t);

    // First call to getSeconds initializes the cache.
    assertEq(d.getSeconds(), t);

    // Second call to getSeconds uses the cached value.
    assertEq(d.getSeconds(), t);
  }
}
testDateGetSeconds();

Messung V0.5 in Prozent
C=85 H=70 G=77

¤ Dauer der Verarbeitung: 0.10 Sekunden  (vorverarbeitet am  2026-06-10) ¤

*© Formatika GbR, Deutschland






Wurzel

Suchen

PVS Prover

Isabelle Prover

NIST Cobol Testsuite

Cephes Mathematical Library

Vienna Development Method

Haftungshinweis

Die Informationen auf dieser Webseite wurden nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit, noch Qualität der bereit gestellten Informationen zugesichert.

Bemerkung:

Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.