Best Python code snippet using autotest_python
YEP_X_SkillCooldowns.js
Source:YEP_X_SkillCooldowns.js  
...932Yanfly.SCD.Game_BattlerBase_meetsSkillConditions =933    Game_BattlerBase.prototype.meetsSkillConditions;934Game_BattlerBase.prototype.meetsSkillConditions = function(skill) {935    if (this.cooldown(skill.id) > 0) return false;936    if (this.warmup(skill.id) > 0) return false;937    return Yanfly.SCD.Game_BattlerBase_meetsSkillConditions.call(this, skill);938};939Yanfly.SCD.Game_BattlerBase_paySkillCost = 940    Game_BattlerBase.prototype.paySkillCost;941Game_BattlerBase.prototype.paySkillCost = function(skill) {942    Yanfly.SCD.Game_BattlerBase_paySkillCost.call(this, skill);943    this.payGlobalCooldown(skill);944    this.payStypeCooldownCost(skill);945    this.payCooldownCost(skill);946    this.applyCooldownMods(skill);947};948Game_BattlerBase.prototype.payGlobalCooldown = function(mainSkill) {949    for (var i = 0; i < this.allSkills().length; ++i) {950      var skill = this.allSkills()[i];951      if (!skill) continue;952      var value = mainSkill.globalCooldown;953      value *= this.cooldownDuration(mainSkill);954      value = Math.max(value, this.cooldown(skill.id));955      this.setCooldown(skill.id, value);956    }957};958Game_BattlerBase.prototype.payStypeCooldownCost = function(mainSkill) {959    for (var stypeId in mainSkill.stypeCooldown) {960      stypeId = parseInt(stypeId);961      for (var i = 0; i < this.allSkills().length; ++i) {962        var skill = this.allSkills()[i];963        if (!skill) continue;964        if (skill.stypeId !== stypeId) continue;965        var value = mainSkill.stypeCooldown[stypeId];966        value *= this.cooldownDuration(mainSkill);967        value = Math.max(value, this.cooldown(skill.id));968        this.setCooldown(skill.id, value);969      }970    }971};972Game_BattlerBase.prototype.payCooldownCost = function(skill) {973    for (var skillId in skill.cooldown) {974      skillId = parseInt(skillId);975      if (!$dataSkills[skillId]) continue;976      var cooldown = skill.cooldown[skillId];977      if (skill.id === skillId) {978        if (skill.cooldownEval.length > 0) {979          var item = skill;980          var a = this;981          var user = this;982          var subject = this;983          var s = $gameSwitches._data;984          var v = $gameVariables._data;985          var code = skill.cooldownEval;986          try {987            eval(code);988          } catch (e) {989            Yanfly.Util.displayError(e, code, 'CUSTOM COOLDOWN EVAL ERROR');990          }991        }992      }993      cooldown *= this.cooldownDuration(skill);994      cooldown = Math.max(cooldown, this.cooldown(skillId));995      this.setCooldown(skillId, cooldown);996    }997};998Game_BattlerBase.prototype.endBattleCooldowns = function() {999    this.resetCooldownTickRates();1000    for (var skillId in this._cooldownTurns) {1001      this._cooldownTurns[skillId] += $dataSkills[skillId].afterBattleCooldown;1002    }1003};1004Game_BattlerBase.prototype.resetCooldownTickRates = function() {1005    this._cooldownTickRate = {};1006};1007Game_BattlerBase.prototype.updateCooldownSteps = function() {1008    for (var skillId in this._cooldownTurns) {1009      var skill = $dataSkills[skillId];1010      if (skill) {1011        if ($gameParty.steps() % skill.cooldownSteps === 0) {1012          this._cooldownTurns[skillId] -= this.cooldownRate(skill);1013        }1014      }1015    }1016};1017Game_BattlerBase.prototype.applyCooldownEffect = function(skill) {1018    this.applyGlobalCooldownChange(skill);1019    this.applyStypeCooldownChange(skill);1020    this.applyCooldownChange(skill);1021};1022Game_BattlerBase.prototype.applyCooldownChange = function(skill) {1023    for (var skillId in skill.cooldownChange) {1024      skillId = parseInt(skillId);1025      if (!$dataSkills[skillId]) continue;1026      if (!skill.cooldownChange[skillId]) continue;1027      var value = skill.cooldownChange[skillId];1028      this.addCooldown(skillId, value);1029    }1030};1031Game_BattlerBase.prototype.applyStypeCooldownChange = function(mainSkill) {1032    for (var stypeId in mainSkill.stypeCooldownChange) {1033      stypeId = parseInt(stypeId);1034      for (var i = 0; i < this.allSkills().length; ++i) {1035        var skill = this.allSkills()[i];1036        if (!skill) continue;1037        if (skill.stypeId !== stypeId) continue;1038        if (!mainSkill.stypeCooldownChange[stypeId]) continue;1039        var value = mainSkill.stypeCooldownChange[stypeId];1040        this.addCooldown(skill.id, value);1041      }1042    }1043};1044Game_BattlerBase.prototype.applyGlobalCooldownChange = function(mainSkill) {1045    for (var i = 0; i < this.allSkills().length; ++i) {1046      var skill = this.allSkills()[i];1047      if (!skill) continue;1048      var value = mainSkill.globalCooldownChange;1049      this.addCooldown(skill.id, value);1050    }1051};1052Game_BattlerBase.prototype.getWarmupMods = function(skill) {1053    var value = 0;1054    value += this.flatWarmupChange(skill);1055    return value;1056};1057Game_BattlerBase.prototype.applyCooldownMods = function(skill) {1058    var value = this.cooldown(skill.id);1059    value += this.flatCooldownChange(skill);1060    this.setCooldown(skill.id, Math.max(0, value));1061};1062//=============================================================================1063// Game_Battler1064//=============================================================================1065Game_Battler.prototype.onBattleStartCooldowns = function() {1066    this.resetCooldownTickRates();1067    this.startWarmups();1068};1069Game_Battler.prototype.cooldownDuration = function(skill) {1070    var skillId = skill.id;1071    var stypeId = skill.stypeId;1072    var value = 1.0;1073    for (var i = 0; i < this.states().length; ++i) {1074      var state = this.states()[i];1075      if (!state) continue;1076      if (state.cooldownDuration[skillId] !== undefined) {1077        value *= state.cooldownDuration[skillId];1078      }1079      if (state.stypeCooldownDuration[stypeId] !== undefined) {1080        value *= state.stypeCooldownDuration[stypeId];1081      }1082      value *= state.globalCooldownDuration;1083    }1084    return value;1085};1086Game_Battler.prototype.cooldownRate = function(skill) {1087    var skillId = skill.id;1088    var stypeId = skill.stypeId;1089    var value = 1;1090    for (var i = 0; i < this.states().length; ++i) {1091      var state = this.states()[i];1092      if (!state) continue;1093      if (state.cooldownRate[skillId] !== undefined) {1094        value *= state.cooldownRate[skillId];1095      }1096      if (state.stypeCooldownRate[stypeId] !== undefined) {1097        value *= state.stypeCooldownRate[stypeId];1098      }1099      value *= state.globalCooldownRate;1100    }1101    return value;1102};1103Game_Battler.prototype.flatCooldownChange = function(skill) {1104    var skillId = skill.id;1105    var stypeId = skill.stypeId;1106    var value = 0;1107    for (var i = 0; i < this.states().length; ++i) {1108      var state = this.states()[i];1109      if (!state) continue;1110      if (state.cooldownChange[skillId] !== undefined) {1111        value += state.cooldownChange[skillId];1112      }1113      if (state.stypeCooldownChange[stypeId] !== undefined) {1114        value += state.stypeCooldownChange[stypeId];1115      }1116      value += state.globalCooldownChange;1117    }1118    return value;1119};1120Game_Battler.prototype.flatWarmupChange = function(skill) {1121    var skillId = skill.id;1122    var stypeId = skill.stypeId;1123    var value = 0;1124    for (var i = 0; i < this.states().length; ++i) {1125      var state = this.states()[i];1126      if (!state) continue;1127      if (state.warmupChange[skillId] !== undefined) {1128        value += state.warmupChange[skillId];1129      }1130      if (state.stypeWarmupChange[stypeId] !== undefined) {1131        value += state.stypeWarmupChange[stypeId];1132      }1133      value += state.globalWarmupChange;1134    }1135    return value;1136};1137Yanfly.SCD.Game_Battler_refresh = Game_Battler.prototype.refresh;1138Game_Battler.prototype.refresh = function() {1139    Yanfly.SCD.Game_Battler_refresh.call(this);1140    this.resetCooldownTickRates();1141};1142if (Imported.YEP_BattleEngineCore) {1143  Yanfly.SCD.Game_Battler_onTurnStart = Game_Battler.prototype.onTurnStart;1144  Game_Battler.prototype.onTurnStart = function() {1145    Yanfly.SCD.Game_Battler_onTurnStart.call(this);1146    if (BattleManager.isTickBased() && !BattleManager.timeBasedCooldowns()) {1147      this.updateCooldowns();1148      this.updateWarmups();1149    }1150  };1151  Yanfly.SCD.Game_Battler_updateTick = Game_Battler.prototype.updateTick;1152  Game_Battler.prototype.updateTick = function() {1153    Yanfly.SCD.Game_Battler_updateTick.call(this);1154    if (BattleManager.isTickBased() && BattleManager.timeBasedCooldowns()) {1155      this.updateCooldownTicks();1156      this.updateWarmupTicks();1157    };1158  };1159}; // Imported.YEP_BattleEngineCore1160Game_Battler.prototype.allSkills = function() {1161  var prevCase = $gameTemp._disableBattleSkills;1162  $gameTemp._disableBattleSkills = true;1163  var skills = this.skills();1164  $gameTemp._disableBattleSkills = prevCase;1165  return skills;1166};1167//=============================================================================1168// Game_Actor1169//=============================================================================1170Game_Actor.prototype.cooldownDuration = function(skill) {1171    var value = Game_Battler.prototype.cooldownDuration.call(this, skill);1172    var skillId = skill.id;1173    var stypeId = skill.stypeId;1174    if (this.actor().cooldownDuration[skillId] !== undefined) {1175      value *= this.actor().cooldownDuration[skillId];1176    }1177    if (this.currentClass().cooldownDuration[skillId] !== undefined) {1178      value *= this.currentClass().cooldownDuration[skillId];1179    }1180    if (this.actor().stypeCooldownDuration[stypeId] !== undefined) {1181      value *= this.actor().stypeCooldownDuration[stypeId];1182    }1183    if (this.currentClass().stypeCooldownDuration[stypeId] !== undefined) {1184      value *= this.currentClass().stypeCooldownDuration[stypeId];1185    }1186    value *= this.actor().globalCooldownDuration;1187    value *= this.currentClass().globalCooldownDuration;1188    for (var i = 0; i < this.equips().length; ++i) {1189      var equip = this.equips()[i];1190      if (!equip) continue;1191      if (equip.cooldownDuration !== undefined) {1192        if (equip.cooldownDuration[skillId] !== undefined) {1193          value *= equip.cooldownDuration[skillId];1194        }1195      }1196      if (equip.stypeCooldownDuration !== undefined) {1197        if (equip.stypeCooldownDuration[stypeId] !== undefined) {1198          value *= equip.stypeCooldownDuration[stypeId];1199        }1200      }1201      if (equip.globalCooldownDuration !== undefined) {1202        value *= equip.globalCooldownDuration;1203      }1204    }1205    return value;1206};1207Game_Actor.prototype.cooldownRate = function(skill) {1208    var value = Game_Battler.prototype.cooldownRate.call(this, skill);1209    var skillId = skill.id;1210    var stypeId = skill.stypeId;1211    if (this.actor().cooldownRate[skillId] !== undefined) {1212      value *= this.actor().cooldownRate[skillId];1213    }1214    if (this.currentClass().cooldownRate[skillId] !== undefined) {1215      value *= this.currentClass().cooldownRate[skillId];1216    }1217    if (this.actor().stypeCooldownRate[stypeId] !== undefined) {1218      value *= this.actor().stypeCooldownRate[stypeId];1219    }1220    if (this.currentClass().stypeCooldownRate[stypeId] !== undefined) {1221      value *= this.currentClass().stypeCooldownRate[stypeId];1222    }1223    value *= this.actor().globalCooldownRate;1224    value *= this.currentClass().globalCooldownRate;1225    for (var i = 0; i < this.equips().length; ++i) {1226      var equip = this.equips()[i];1227      if (!equip) continue;1228      if (equip.cooldownRate !== undefined) {1229        if (equip.cooldownRate[skillId] !== undefined) {1230          value *= equip.cooldownRate[skillId];1231        }1232      }1233      if (equip.stypeCooldownRate !== undefined) {1234        if (equip.stypeCooldownRate[stypeId] !== undefined) {1235          value *= equip.stypeCooldownRate[stypeId];1236        }1237      }1238      if (equip.globalCooldownRate !== undefined) {1239        value *= equip.globalCooldownRate;1240      }1241    }1242    return value;1243};1244Game_Actor.prototype.flatCooldownChange = function(skill) {1245    var skillId = skill.id;1246    var stypeId = skill.stypeId;1247    var value = Game_Battler.prototype.flatCooldownChange.call(this, skill);1248    if (this.actor().cooldownChange[skillId] !== undefined) {1249      value += this.actor().cooldownChange[skillId];1250    }1251    if (this.currentClass().cooldownChange[skillId] !== undefined) {1252      value += this.currentClass().cooldownChange[skillId];1253    }1254    if (this.actor().stypeCooldownChange[stypeId] !== undefined) {1255      value += this.actor().stypeCooldownChange[stypeId];1256    }1257    if (this.currentClass().stypeCooldownChange[stypeId] !== undefined) {1258      value += this.currentClass().stypeCooldownChange[stypeId];1259    }1260    value += this.actor().globalCooldownChange;1261    value += this.currentClass().globalCooldownChange;1262    for (var i = 0; i < this.equips().length; ++i) {1263      var equip = this.equips()[i];1264      if (!equip) continue;1265      if (equip.cooldownChange === undefined) continue;1266      if (equip.cooldownChange[skillId] !== undefined) {1267        value += equip.cooldownChange[skillId];1268      }1269      if (equip.stypeCooldownChange[stypeId] !== undefined) {1270        value += equip.stypeCooldownChange[stypeId];1271      }1272      value += equip.globalCooldownChange;1273    }1274    return value;1275};1276Game_Actor.prototype.flatWarmupChange = function(skill) {1277    var skillId = skill.id;1278    var stypeId = skill.stypeId;1279    var value = Game_Battler.prototype.flatWarmupChange.call(this, skill);1280    if (this.actor().warmupChange[skillId] !== undefined) {1281      value += this.actor().warmupChange[skillId];1282    }1283    if (this.currentClass().warmupChange[skillId] !== undefined) {1284      value += this.currentClass().warmupChange[skillId];1285    }1286    if (this.actor().stypeWarmupChange[stypeId] !== undefined) {1287      value += this.actor().stypeWarmupChange[stypeId];1288    }1289    if (this.currentClass().stypeWarmupChange[stypeId] !== undefined) {1290      value += this.currentClass().stypeWarmupChange[stypeId];1291    }1292    value += this.actor().globalWarmupChange;1293    value += this.currentClass().globalWarmupChange;1294    for (var i = 0; i < this.equips().length; ++i) {1295      var equip = this.equips()[i];1296      if (!equip) continue;1297      if (equip.warmupChange === undefined) continue;1298      if (equip.warmupChange[skillId] !== undefined) {1299        value += equip.warmupChange[skillId];1300      }1301      if (equip.stypeWarmupChange[stypeId] !== undefined) {1302        value += equip.stypeWarmupChange[stypeId];1303      }1304      value += equip.globalWarmupChange;1305    }1306    return value;1307};1308//=============================================================================1309// Game_Enemy1310//=============================================================================1311if (!Game_Enemy.prototype.skills) {1312    Game_Enemy.prototype.skills = function() {1313      var skills = []1314      for (var i = 0; i < this.enemy().actions.length; ++i) {1315        var skill = $dataSkills[this.enemy().actions[i].skillId]1316        if (skill) skills.push(skill);1317      }1318      return skills;1319    }1320};1321Game_Enemy.prototype.cooldownDuration = function(skill) {1322    var value = Game_Battler.prototype.cooldownDuration.call(this, skill);1323    var skillId = skill.id;1324    var stypeId = skill.stypeId;1325    if (this.enemy().cooldownDuration[skillId] !== undefined) {1326      value *= this.enemy().cooldownDuration[skillId];1327    }1328    if (this.enemy().stypeCooldownDuration[stypeId] !== undefined) {1329      value *= this.enemy().stypeCooldownDuration[stypeId];1330    }1331    value *= this.enemy().globalCooldownDuration;1332    return value;1333};1334Game_Enemy.prototype.cooldownRate = function(skill) {1335    var value = Game_Battler.prototype.cooldownRate.call(this, skill);1336    var skillId = skill.id;1337    var stypeId = skill.stypeId;1338    if (this.enemy().cooldownRate[skillId] !== undefined) {1339      value *= this.enemy().cooldownRate[skillId];1340    }1341    if (this.enemy().stypeCooldownRate[stypeId] !== undefined) {1342      value *= this.enemy().stypeCooldownRate[stypeId];1343    }1344    value *= this.enemy().globalCooldownRate;1345    return value;1346};1347Game_Enemy.prototype.flatCooldownChange = function(skill) {1348    var skillId = skill.id;1349    var stypeId = skill.stypeId;1350    var value = Game_Battler.prototype.flatCooldownChange.call(this, skill);1351    if (this.enemy().cooldownChange[skillId] !== undefined) {1352      value += this.enemy().cooldownChange[skillId];1353    }1354    if (this.enemy().stypeCooldownChange[stypeId] !== undefined) {1355      value += this.enemy().stypeCooldownChange[stypeId];1356    }1357    value += this.enemy().globalCooldownChange;1358    return value;1359};1360Game_Enemy.prototype.flatWarmupChange = function(skill) {1361    var skillId = skill.id;1362    var stypeId = skill.stypeId;1363    var value = Game_Battler.prototype.flatWarmupChange.call(this, skill);1364    if (this.enemy().warmupChange[skillId] !== undefined) {1365      value += this.enemy().warmupChange[skillId];1366    }1367    if (this.enemy().stypeWarmupChange[stypeId] !== undefined) {1368      value += this.enemy().stypeWarmupChange[stypeId];1369    }1370    value += this.enemy().globalWarmupChange;1371    return value;1372};1373//=============================================================================1374// Game_Action1375//=============================================================================1376Yanfly.SCD.Game_Action_applyItemUserEffect =1377    Game_Action.prototype.applyItemUserEffect;1378Game_Action.prototype.applyItemUserEffect = function(target) {1379    Yanfly.SCD.Game_Action_applyItemUserEffect.call(this, target);1380    if (target) target.applyCooldownEffect(this.item());1381};1382//=============================================================================1383// Game_Unit1384//=============================================================================1385Yanfly.SCD.Game_Unit_onBattleStart = Game_Unit.prototype.onBattleStart;1386Game_Unit.prototype.onBattleStart = function() {1387  Yanfly.SCD.Game_Unit_onBattleStart.call(this);1388  this.onBattleStartCooldowns();1389};1390Game_Unit.prototype.onBattleStartCooldowns = function() {1391  var members = this.cooldownMembers();1392  var length = members.length1393  for (var i = 0; i < length; ++i) {1394    var member = members[i];1395    if (member) member.onBattleStartCooldowns();1396  }1397};1398Game_Unit.prototype.updateCooldowns = function() {1399  if (BattleManager.timeBasedCooldowns()) return;1400  var members = this.members();1401  var length = members.length1402  for (var i = 0; i < length; ++i) {1403    var member = members[i];1404    if (member) {1405      member.updateCooldowns();1406      member.updateWarmups();1407    }1408  }1409};1410Game_Unit.prototype.endBattleCooldowns = function() {1411  var members = this.members();1412  var length = members.length1413  for (var i = 0; i < length; ++i) {1414    var member = members[i];1415    if (member) {1416      member.endBattleCooldowns();1417      member.clearWarmups();1418    }1419  }1420};1421Game_Unit.prototype.cooldownMembers = function() {1422  return this.members();1423};1424//=============================================================================1425// Game_Party1426//=============================================================================1427Yanfly.SCD.Game_Party_increaseSteps = Game_Party.prototype.increaseSteps;1428Game_Party.prototype.increaseSteps = function() {1429    Yanfly.SCD.Game_Party_increaseSteps.call(this);1430    this.updateCooldownSteps();1431};1432Game_Party.prototype.updateCooldownSteps = function() {1433    return this.members().forEach(function(member) {1434        return member.updateCooldownSteps();1435    });1436};1437Game_Party.prototype.cooldownMembers = function() {1438  return this.allMembers();1439};1440//=============================================================================1441// Game_Troop1442//=============================================================================1443Yanfly.SCD.Game_Troop_increaseTurn = Game_Troop.prototype.increaseTurn;1444Game_Troop.prototype.increaseTurn = function() {1445    Yanfly.SCD.Game_Troop_increaseTurn.call(this);1446    if (Imported.YEP_BattleEngineCore) {1447      if (BattleManager.isTurnBased()) {1448        this.updateCooldowns();1449        $gameParty.updateCooldowns();1450      }1451    } else {1452      this.updateCooldowns();1453      $gameParty.updateCooldowns();1454    }1455};1456//=============================================================================1457// Window_SkillList1458//=============================================================================1459Yanfly.SCD.Window_SkillList_drawCost = Window_SkillList.prototype.drawSkillCost;1460Window_SkillList.prototype.drawSkillCost = function(skill, wx, wy, ww) {1461    if (this._actor.warmup(skill.id) > 0) {1462      return this.drawWarmup(skill, wx, wy, ww);1463    } else if (this._actor.cooldown(skill.id) > 0) {1464      return this.drawCooldown(skill, wx, wy, ww);1465    } else {1466      return Yanfly.SCD.Window_SkillList_drawCost.call(this, skill, wx, wy, ww);1467    }1468};1469Window_SkillList.prototype.drawCooldown = function(skill, wx, wy, dw) {1470    if (Yanfly.Icon.Cooldown > 0) {1471      var iw = wx + dw - Window_Base._iconWidth;1472      this.drawIcon(Yanfly.Icon.Cooldown, iw, wy + 2);1473      dw -= Window_Base._iconWidth + 2;1474    }1475    this.changeTextColor(this.textColor(Yanfly.Param.CDTextColor));1476    var fmt = Yanfly.Param.CDFmt;1477    var value = this._actor.cooldown(skill.id);1478    if (value % 1 !== 0) value = value.toFixed(2);1479    if (value <= 0.009) value = 0.01;1480    var text = fmt.format(Yanfly.Util.toGroup(value));1481    this.contents.fontSize = Yanfly.Param.CDFontSize;1482    this.drawText(text, wx, wy, dw, 'right');1483    var returnWidth = dw - this.textWidth(text) - Yanfly.Param.SCCCostPadding;1484    this.resetFontSettings();1485    return returnWidth;1486};1487Window_SkillList.prototype.drawWarmup = function(skill, wx, wy, dw) {1488    if (Yanfly.Icon.Warmup > 0) {1489      var iw = wx + dw - Window_Base._iconWidth;1490      this.drawIcon(Yanfly.Icon.Warmup, iw, wy + 2);1491      dw -= Window_Base._iconWidth + 2;1492    }1493    this.changeTextColor(this.textColor(Yanfly.Param.WUTextColor));1494    var fmt = Yanfly.Param.WUFmt;1495    var value = this._actor.warmup(skill.id);1496    if (value % 1 !== 0) value = value.toFixed(2);1497    if (value <= 0.009) value = 0.01;1498    var text = fmt.format(Yanfly.Util.toGroup(value));1499    this.contents.fontSize = Yanfly.Param.WUFontSize;1500    this.drawText(text, wx, wy, dw, 'right');1501    var returnWidth = dw - this.textWidth(text) - Yanfly.Param.SCCCostPadding;1502    this.resetFontSettings();1503    return returnWidth;1504};1505//=============================================================================1506// Utilities1507//=============================================================================1508Yanfly.Util = Yanfly.Util || {};1509if (!Yanfly.Util.toGroup) {...CacheWarmupMenu.ts
Source:CacheWarmupMenu.ts  
1'use strict'2/*3 * This file is part of the TYPO3 CMS extension "warming".4 *5 * Copyright (C) 2021 Elias HäuÃler <elias@haeussler.dev>6 *7 * This program is free software: you can redistribute it and/or modify8 * it under the terms of the GNU General Public License as published by9 * the Free Software Foundation, either version 2 of the License, or10 * (at your option) any later version.11 *12 * This program is distributed in the hope that it will be useful,13 * but WITHOUT ANY WARRANTY; without even the implied warranty of14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the15 * GNU General Public License for more details.16 *17 * You should have received a copy of the GNU General Public License18 * along with this program. If not, see <https://www.gnu.org/licenses/>.19 */20import 'select2';21import * as clipboard from 'clipboard-polyfill/text';22import IconIdentifiers from '../../../lib/Enums/IconIdentifiers';23import LanguageKeys from '../../../lib/Enums/LanguageKeys';24import WarmupProgress from '../../../lib/WarmupProgress';25import WarmupRequest from '../../../lib/WarmupRequest';26import WarmupRequestMode from '../../../lib/Enums/WarmupRequestMode';27import WarmupRequestType from '../../../lib/Enums/WarmupRequestType';28import WarmupState from '../../../lib/Enums/WarmupState';29// Modules30import $ from 'jquery';31import ImmediateAction from "TYPO3/CMS/Backend/ActionButton/ImmediateAction";32import Icons from 'TYPO3/CMS/Backend/Icons';33import Notification from 'TYPO3/CMS/Backend/Notification';34import Viewport from 'TYPO3/CMS/Backend/Viewport';35import AjaxRequest from 'TYPO3/CMS/Core/Ajax/AjaxRequest';36import AjaxResponse from 'TYPO3/CMS/Core/Ajax/AjaxResponse';37import CacheWarmupProgressModal from '../Modal/CacheWarmupProgressModal';38import CacheWarmupReportModal from '../Modal/CacheWarmupReportModal';39/**40 * Selectors for several components within cache warmup menu.41 *42 * @author Elias HäuÃler <elias@haeussler.dev>43 * @license GPL-2.0-or-later44 */45enum CacheWarmupMenuSelectors {46  container = '#eliashaeussler-typo3warming-backend-toolbaritems-cachewarmuptoolbaritem',47  dropdownTable = '.dropdown-table',48  menuItem = 'a.toolbar-cache-warmup-action',49  toolbarIcon = '.toolbar-item-icon .t3js-icon',50  languageSelect = '.tx-warming-language-select',51  languageSelectWrapper = '.tx-warming-language-select-wrapper',52  languageSelectDropdown = '.tx-warming-language-select-dropdown',53  useragentCopy = 'button.toolbar-cache-warmup-useragent-copy-action',54  useragentCopyIcon = '.t3js-icon',55  useragentCopyText = '.toolbar-cache-warmup-useragent-copy-text',56}57/**58 * AMD module that handles cache warmup from the Backend toolbar.59 *60 * Module: TYPO3/CMS/Warming/Backend/Toolbar/CacheWarmupMenu61 *62 * @author Elias HäuÃler <elias@haeussler.dev>63 * @license GPL-2.0-or-later64 */65export class CacheWarmupMenu {66  private notificationDuration = 15;67  constructor() {68    Viewport.Topbar.Toolbar.registerEvent((): void => this.fetchSites());69    // Copy user agent to clipboard in case the copy button is clicked70    $(CacheWarmupMenuSelectors.container).on('click', CacheWarmupMenuSelectors.useragentCopy, (event: JQuery.TriggeredEvent): void => {71      event.preventDefault();72      event.stopImmediatePropagation();73      const userAgent = $(event.currentTarget).attr('data-text');74      if (userAgent) {75        this.copyUserAgentToClipboard(userAgent);76      }77    });78  }79  /**80   * Trigger cache warmup for given page in given mode.81   *82   * Creates a new object of {@link WarmupRequest} for the given page id and warmup83   * request mode and starts cache warmup. In the meantime, the toolbar icon is84   * replaced by a spinner indicating that a cache warmup is in progress. Once the85   * cache warmup is finished, a notification is shown. If it fails, an error86   * notification is shown instead.87   *88   * @param pageId {number} Root page ID whose caches should be warmed up89   * @param mode {WarmupRequestMode} Requested warmup request mode90   * @param languageId {number|null} Optional language ID of a specific site language whose caches should be warmed up91   */92  public warmupCache(pageId: number, mode: WarmupRequestMode = WarmupRequestMode.Site, languageId: number | null = null): void {93    const $toolbarItemIcon = $(CacheWarmupMenuSelectors.toolbarIcon, CacheWarmupMenuSelectors.container);94    const $existingIcon = $toolbarItemIcon.clone();95    // Close dropdown menu96    $(CacheWarmupMenuSelectors.container).removeClass('open');97    // Show spinner during cache warmup98    Icons.getIcon(IconIdentifiers.spinner, Icons.sizes.small).then((spinner: string): void => {99      $toolbarItemIcon.replaceWith(spinner);100    });101    const request = new WarmupRequest(pageId, mode, languageId);102    request.runWarmup()103      .then(104        // Success105        (data: WarmupProgress): void => {106          let action;107          // Add option to restart cache warmup if it has been aborted108          if (WarmupState.Aborted === data.state) {109            action = {110              label: TYPO3.lang[LanguageKeys.notificationActionRetry],111              action: new ImmediateAction((): void => this.warmupCache(pageId, mode, languageId)),112            };113          }114          this.showNotification(data, action);115          // Apply trigger function to "retry" button of progress modal116          if (WarmupRequestType.EventSource === request.requestType && WarmupState.Aborted !== data.state) {117            CacheWarmupProgressModal.getRetryButton()118              .removeClass('hidden')119              .off('button.clicked')120              .on('button.clicked', (): void => this.warmupCache(pageId, mode, languageId));121          }122        },123        // Error124        (): void => CacheWarmupMenu.errorNotification(),125      )126      .finally((): void => {127        $(CacheWarmupMenuSelectors.toolbarIcon, CacheWarmupMenuSelectors.container).replaceWith($existingIcon);128      });129  }130  /**131   * Fetch sites that are available for cache warmup.132   *133   * Creates an AJAX request to fetch all available sites that are ready for134   * cache warmup and replaces the table in the toolbar menu item with the135   * fetched content.136   *137   * @private138   */139  private fetchSites(): void {140    const $toolbarItemIcon = $(CacheWarmupMenuSelectors.toolbarIcon, CacheWarmupMenuSelectors.container);141    const $existingIcon = $toolbarItemIcon.clone();142    // Close dropdown menu143    $(CacheWarmupMenuSelectors.container).removeClass('open');144    // Show spinner during cache warmup145    Icons.getIcon(IconIdentifiers.spinner, Icons.sizes.small).then((spinner: string): void => {146      $toolbarItemIcon.replaceWith(spinner);147    });148    // Fetch rendered sites149    (new AjaxRequest(TYPO3.settings.ajaxUrls.tx_warming_fetch_sites))150      .get()151      .then(152        async (response: typeof AjaxResponse): Promise<void> => {153          // Replace placeholder with real data154          const data = await response.resolve();155          $(CacheWarmupMenuSelectors.dropdownTable, CacheWarmupMenuSelectors.container).html(data);156          // Initialize events for inserted DOM elements157          this.initializeEvents();158        }159      )160      .finally((): void => {161        $(CacheWarmupMenuSelectors.toolbarIcon, CacheWarmupMenuSelectors.container).replaceWith($existingIcon);162      });163  }164  /**165   * Initialize DOM events for several components in the cache warmup menu.166   *167   * @private168   */169  private initializeEvents(): void {170    // Trigger cache warmup in case a menu item is clicked171    $(CacheWarmupMenuSelectors.container).on('click', CacheWarmupMenuSelectors.menuItem, (event: JQuery.TriggeredEvent): void => {172      event.preventDefault();173      const pageId = $(event.currentTarget).attr('data-page-id');174      if (pageId) {175        this.warmupCache(Number(pageId));176      }177    });178    const $languageSelectWrapper = $(CacheWarmupMenuSelectors.languageSelectWrapper, CacheWarmupMenuSelectors.container);179    const $languageSelect = $(CacheWarmupMenuSelectors.languageSelect, $languageSelectWrapper);180    // Initialize select2 element for language selections181    $languageSelect.select2({182      placeholder: {183        // Use first select option with value="null" (disabled) as placeholder184        id: 'null',185        text: TYPO3.lang[LanguageKeys.toolbarSitemapPlaceholder],186      },187      // Disable search form188      minimumResultsForSearch: Infinity,189      width: '100%',190      dropdownCssClass: 'tx-warming-language-select-dropdown',191      dropdownAutoWidth: true,192      templateResult: (state: Select2.LoadingData): JQuery | null => {193        // Only valid language options are supported194        if (!state.id) {195          return null;196        }197        // Build option element from icon (flag) and text198        const $element = $(state.element as unknown as string);199        const $flag = $('<span class="tx-warming-language-select-option-flag">').append($element.data('icon'));200        const $content = $('<span class="tx-warming-language-select-option-text">').append(201          $('<strong>').text(state.text),202          $('<br>')203        );204        // Add sitemap URL or error message to option element205        if ($element.data('missing')) {206          $content.append(TYPO3.lang[LanguageKeys.toolbarSitemapMissing]);207        } else {208          $content.append($element.data('sitemap-url'));209        }210        // Create and return final option element211        return $('<span class="tx-warming-language-select-option">').append($flag, $content);212      }213    });214    // Prevent Bootstrap from closing toolbar item (= dropdown)215    // when language select menu is opened or interacted with216    $languageSelectWrapper.on('click', '.select2', (event: JQuery.TriggeredEvent): void => {217      event.preventDefault();218      event.stopImmediatePropagation();219    });220    $languageSelect.on('select2:open', (): void => {221      const $dropdown = $(CacheWarmupMenuSelectors.languageSelectDropdown);222      $dropdown.off('click', 'li');223      $dropdown.on('click', 'li', (event: JQuery.TriggeredEvent): void => {224        event.preventDefault();225        event.stopImmediatePropagation();226      });227    });228    // Trigger warmup for a concrete language229    $languageSelect.on('change', (event: JQuery.TriggeredEvent): void => {230      const $selectedOption = $(event.target).find(':selected');231      const pageId = $selectedOption.data('page-id');232      const languageId = $selectedOption.val();233      if (pageId && 'string' === typeof languageId) {234        // Trigger cache warmup for page and language235        this.warmupCache(Number(pageId), WarmupRequestMode.Site, Number(languageId));236        // Reset language selection to placeholder option237        $(event.target).val('null').trigger('change');238      }239    });240  }241  /**242   * Copy given User-Agent header to clipboard.243   *244   * @param userAgent {string} User-Agent header to be copied to clipboard245   * @private246   */247  private copyUserAgentToClipboard(userAgent: string): void {248    const $copyIcon = $(CacheWarmupMenuSelectors.useragentCopyIcon, CacheWarmupMenuSelectors.useragentCopy);249    const $existingIcon = $copyIcon.clone();250    // Show spinner when copying user agent251    Icons.getIcon(IconIdentifiers.spinner, Icons.sizes.small).then((spinner: string): void => {252      $copyIcon.replaceWith(spinner);253    });254    // Copy user agent to clipboard255    Promise.all([256      (navigator.clipboard ?? clipboard).writeText(userAgent),257      Icons.getIcon(IconIdentifiers.check, Icons.sizes.small),258    ])259      .then(260        async ([, icon]): Promise<void> => {261          const existingText = $(CacheWarmupMenuSelectors.useragentCopyText).text();262          $(CacheWarmupMenuSelectors.useragentCopyText).text(TYPO3.lang[LanguageKeys.toolbarCopySuccessful]);263          $(CacheWarmupMenuSelectors.useragentCopyIcon, CacheWarmupMenuSelectors.useragentCopy).replaceWith(icon);264          // Restore copy button after 3 seconds265          window.setTimeout((): void => {266            $(CacheWarmupMenuSelectors.useragentCopyIcon, CacheWarmupMenuSelectors.useragentCopy).replaceWith($existingIcon);267            $(CacheWarmupMenuSelectors.useragentCopyText).text(existingText);268            $(CacheWarmupMenuSelectors.useragentCopy).trigger('blur');269          }, 3000);270        },271        (): void => {272          $(CacheWarmupMenuSelectors.useragentCopyIcon, CacheWarmupMenuSelectors.useragentCopy).replaceWith($existingIcon);273        }274      );275  }276  /**277   * Show notification for given cache warmup progress.278   *279   * @param progress {WarmupProgress} Progress of the cache warmup a notification is built for280   * @param additionalAction {object|null} Additional action to be used for the generated notification281   * @private282   */283  private showNotification(progress: WarmupProgress, additionalAction?: { label: string, action: typeof ImmediateAction }): void {284    let {title, message} = progress.response;285    // Create action to open full report as modal286    const reportAction = CacheWarmupReportModal.createModalAction(progress);287    // Define modal actions288    const actions = [reportAction];289    if (additionalAction) {290      actions.push(additionalAction);291    }292    // Show notification293    switch (progress.state) {294      case WarmupState.Failed:295        Notification.error(title, message, this.notificationDuration, actions);296        break;297      case WarmupState.Warning:298        Notification.warning(title, message, this.notificationDuration, actions);299        break;300      case WarmupState.Success:301        Notification.success(title, message, this.notificationDuration, actions);302        break;303      case WarmupState.Aborted:304        title = TYPO3.lang[LanguageKeys.notificationAbortedTitle];305        message = TYPO3.lang[LanguageKeys.notificationAbortedMessage];306        Notification.info(title, message, this.notificationDuration, actions);307        break;308      case WarmupState.Unknown:309        Notification.notice(title, message, this.notificationDuration);310        break;311      default:312        CacheWarmupMenu.errorNotification();313        break;314    }315  }316  /**317   * Show error notification on erroneous cache warmup.318   *319   * @private320   */321  private static errorNotification(): void {322    Notification.error(TYPO3.lang[LanguageKeys.notificationErrorTitle], TYPO3.lang[LanguageKeys.notificationErrorMessage]);323  }324}...binaryarith.js
Source:binaryarith.js  
1setJitCompilerOption('ion.forceinlineCaches', 1);2function warmup(fun, input_array) {3    for (var index = 0; index < input_array.length; index++) {4        input = input_array[index];5        input_lhs = input[0];6        input_rhs = input[1];7        output    = input[2];8        for (var i = 0; i < 30; i++) {9            var y = fun(input_lhs, input_rhs);10            assertEq(y, output)11        }12    }13}14// Add: Int32 + Int32 Overflow15var funAdd1 = (a, b) => { return a + b; }16warmup(funAdd1, [[1,2, 3], [3,4, 7], [4294967295, 2, 4294967297]]);17// Add: Doubles18var funAdd2 = (a, b) => { return a + b; }19warmup(funAdd2, [[1.2, 2, 3.2], [3.5, 4, 7.5], [4294967295.1, 2, 4294967297.1]]);20// Add: Type Change Int32 -> Double21var funAdd3 = (a, b) => { return a + b; }22warmup(funAdd3, [[1, 2, 3], [3, 4, 7], [4294967295, 2, 4294967297], [1.2, 2, 3.2]]);23//Add: String Concat24var funAdd4 = (a, b) => { return a + b; }25warmup(funAdd4, [["","a","a"], ["ab","ba","abba"], ["123","456","123456"]])26function D(name) { this.name = name; }27D.prototype.toString = function stringify() {28    return this.name;29}30obj1 = new D('A');31// Add: String Object Concat32var funAdd4 = (a, b) => { return a + b; }33warmup(funAdd4, [["x", obj1, "xA"], [obj1, "bba", "Abba"]]);34// Add: Int32 Boolean35var funAdd5 = (a, b) => { return a + b; }36warmup(funAdd5, [[true, 10, 11], [false, 1, 1], [10, true, 11], [1, false, 1],37                 [2147483647, true, 2147483648],[true, 2147483647, 2147483648]]);38// Add: String Number Concat39var funAdd6 = (a, b) => { return a + b; }40warmup(funAdd6, [["x", 10, "x10"], [10, "bba", "10bba"], ["x", 1.2, "x1.2"],41                 [1.2, "bba", "1.2bba"]]);42// Add: String Boolean43var funAddStrBool = (a, b) => { return a + b; }44warmup(funAddStrBool, [[true, "true", "truetrue"], [false, "true", "falsetrue"],45  ["a string", true, "a stringtrue"]]);46// Sub Int3247var funSub1 = (a, b) => { return a - b; }48warmup(funSub1, [[7, 0, 7], [7, 8, -1], [4294967295, 2, 4294967293], [0,0,0]]);49// Sub Double50var funSub2 = (a, b) => { return a - b; }51warmup(funSub2, [[7.5, 0, 7.5], [7, 8.125, -1.125], [4294967295.3125, 2, 4294967293.3125], [NaN,10,NaN]]);52// Sub Int32 + Boolean53var funSub3 = (a, b) => { return a - b; }54warmup(funSub3, [[7, false, 7], [7, true, 6], [false, 1, -1], [true,1,0]]);55// Mul: Int32+  Int32 Overflow56var funMul1 = (a, b) => { return a * b; }57warmup(funMul1, [[1, 2, 2], [10, 21, 210], [3, 4, 12], [2147483649, 2, 4294967298], [1073741824, 1024, 1099511627776 ]]);58// Mul: Doubles59var funMul2 = (a, b) => { return a * b; }60warmup(funMul2, [[3/32, 32, 3], [16/64, 32, 8], [3.0, 1.0, 3], [-1, 0, -0], [0, -20, -0]]);61// Mul: Type change Int32 -> Double62var funMul3 = (a, b) => { return a * b; }63warmup(funMul3, [[1,2, 2], [10, 21, 210], [3, 4, 12], [63/32, 32, 63], [16/64, 32, 8]]);64// Mul: Boolean65var funMul1 = (a, b) => { return a * b; }66warmup(funMul1, [[1, true, 1], [10, false, 0], [false, 4, 0], [2147483640, true, 2147483640]]);67//Div: Int3268var funDiv1 = (a,b) => { return a / b;}69warmup(funDiv1,[[8, 4, 2], [16, 32, 0.5], [10, 0, Infinity], [0, 0, NaN]]);70//Div: Double71var funDiv2 = (a,b) => { return a / b;}72warmup(funDiv2, [[8.8, 4, 2.2], [16.8, 32, 0.525], [10, 0.5, 20]]);73//Div: Type change Int32 -> Double74var funDiv3 = (a,b) => { return a / b;}75warmup(funDiv1, [[8, 4, 2], [16, 32, 0.5], [10, 0, Infinity], [0, 0, NaN], [8.8, 4, 2.2],76                 [16.8, 32, 0.525], [10, 0.5, 20]]);77//Div: Boolean w/ Int3278var funDiv4 = (a,b) => { return a / b;}79warmup(funDiv4,[[8, true, 8], [true, 2, 0.5], [10, false, Infinity], [false, false, NaN]]);80//Mod: Int3281var funMod1 = (a,b) => {return a % b};82warmup(funMod1, [[8, 4, 0], [9, 4, 1], [-1, 2, -1], [4294967297, 2, 1],83                 [10, -3, 1]]);84//Mod: Double85var funMod2 = (a,b) => {return a % b};86warmup(funMod2, [[8.5, 1, 0.5], [9.5, 0.5, 0], [-0.03125, 0.0625, -0.03125], [1.64, 1.16, 0.48]]);87//Mod: Type change Int32 -> Double88var funMod3 = (a,b) => {return a % b};89warmup(funMod3, [[10, 0, NaN], [8, 4, 0], [9, 4, 1], [-1, 2, -1], [4294967297, 2, 1],90                 [8.5, 1, 0.5], [9.5, 0.5, 0], [-0.03125, 0.0625, -0.03125],91                 [1.64, 1.16, 0.48]]);92//Mod: Boolean w/ Int3293var funMod4 = (a,b) => {return a % b};94warmup(funMod4, [[10, false, NaN], [8, true, 0], [false, 4, 0], [true, 2, 1]]);95//Pow: Int3296var funPow1 = (a,b) => {return a ** b};97warmup(funPow1, [[8, 4, 4096], [9, 4, 6561], [-1, 2, 1], [2, -10000, 0],98               [-3, 3, -27]]);99//Pow: Double100var funPow2 = (a,b) => {return a ** b};101warmup(funPow2, [[8.5, 1, 8.5], [16, 0.5, 4], [4.5, 5, 1845.28125], [18.0625, 0.5, 4.25],102                 [4, -1, 0.25]]);103//Pow: Type change Int32 -> Double104var funPow3 = (a,b) => {return a ** b};105warmup(funPow3, [[10, 0, 1], [8, 4, 4096], [9, 4, 6561], [-1, 2, 1], [2, -10000, 0],106                 [8.5, 1, 8.5], [16, 0.5, 4], [4.5, 5, 1845.28125], [18.0625, 0.5, 4.25],107                 [4, -1, 0.25]]);108//Pow: Boolean w/ Int32109var funPow4 = (a,b) => {return a ** b};110warmup(funPow4, [[10, 2, 100], [8, true, 8], [false, 4, 0], [true, 2, 1]]);111//BitOr Int32112var funBitOr1 = (a, b) => { return a | b; }113warmup(funBitOr1, [[1, 1, 1], [8, 1, 9], [0, 1233, 1233], [5, 0, 5],114                   [4294967295, 123231, -1], [2147483647, 1243524, 2147483647]]);115//BitOr  Boolean w/ Int32116var funBitOr3 = (a, b) => { return a | b; }117warmup(funBitOr3, [[1, true, 1], [8, true, 9], [false, 1233, 1233], [5, false, 5]]);118//BitOr  null w/ Int32119var funBitOr4 = (a, b) => { return a | b; }120warmup(funBitOr4, [[1, null, 1], [8, null, 8], [null, 1233, 1233], [5, null, 5]]);121//BitOr  undefined w/ Int32122var funBitOr5 = (a, b) => { return a | b; }123warmup(funBitOr5, [[1, void 0, 1], [8, void 0, 8], [void 0, 1233, 1233], [5, void 0, 5]]);124//BitXOr Int32125var funBitXOr1 = (a, b) => { return a ^ b; }126warmup(funBitXOr1, [[1, 1, 0], [5, 1, 4], [63, 31, 32], [4294967295, 2147483647, -2147483648 ] ]);127//BitXOr Int32128var funBitXOr2 = (a, b) => { return a ^ b; }129warmup(funBitXOr2, [[1, true, 0], [5, true, 4], [5, false, 5], [false, 1, 1]]);130//BitXOr Double+int32131var funBitXOr3 = (a, b) => { return a ^ b; }132warmup(funBitXOr3, [[1.3, 1, 0], [5, 1.4, 4], [63.1, 31, 32], [4294967295.9, 2147483647, -2147483648 ] ]);133//BitXOr Number Number134var funBitXOr4 = (a, b) => { return a ^ b; }135warmup(funBitXOr4, [[54772703898, 2890608493, 1828589047],136                    [-54772703898, 2890608493, -1828589045],137                    [18446744073709551615, 54772703898, -1061870950], //UINT64 Max138                    [-18446744073709551615, 54772703898, -1061870950],139                    [4294967295, -1, 0]]);140//BitXOr null+int32141var funBitXOr5 = (a, b) => { return a ^ b; }142warmup(funBitXOr5, [[1, null, 1], [5, null, 5], [5, null, 5], [null, 1, 1]]);143//BitXOr undefined+int32144var funBitXOr6 = (a, b) => { return a ^ b; }145warmup(funBitXOr6, [[1, void 0, 1], [5, void 0, 5], [5, void 0, 5], [void 0, 1, 1]]);146//BitAnd Int32147var funBitAnd1 = (a, b) => { return a & b; }148warmup(funBitAnd1, [[1,1,1], [5,1,1], [63,31,31], [4294967295,2147483647,2147483647],149                    [-2,10,10], [-15,-2,-16], [4,128,0]]);150//BitAnd Double w/ Int32151var funBitAnd2 = (a, b) => { return a & b; }152warmup(funBitAnd2, [[1.2 ,1, 1], [5, 1.4, 1], [63,31.99,31],153                    [4294967295.98,2147483647,2147483647],154                    [-2.9, 10, 10], [-15,-2.9,-16], [4,128.01,0]]);155//BitAnd Int32 + Boolean156var funBitAnd1 = (a, b) => { return a & b; }157warmup(funBitAnd1, [[1,true,1], [5,false,0], [true, 6, 0], [false, 12, 0]]);158//BitAnd Int32 + null159var funBitAnd4 = (a, b) => { return a & b; }160warmup(funBitAnd4, [[1, null, 0], [5, null, 0], [null, 6, 0], [null, 12, 0]]);161//BitAnd Int32 + undefined162var funBitAnd5 = (a, b) => { return a & b; }163warmup(funBitAnd5, [[1, void 0, 0], [5, void 0, 0], [void 0, 6, 0], [void 0, 12, 0]]);164//Lsh Int32165var funLsh1 = (a, b) => { return a << b; }166warmup(funLsh1, [[5,1,10], [1,1,2], [63,31,-2147483648],167                 [4294967295,2147483647,-2147483648], [-2,10,-2048], [-15,-2,1073741824],168                 [4,128,4], [1,10,1024], [1024,2,4096]]);169//Lsh Boolean w/ Int32170var funLsh2 = (a, b) => { return a << b; }171warmup(funLsh2, [[5,true,10], [true,1,2], [63,false,63], [false, 12, 0]]);172//Lsh Number Number173var funLsh3 = (a, b) => { return a << b; }174warmup(funLsh3, [[54772703898, 1, -2123741900],[2147483658, 0, -2147483638]]);175//Lsh Boolean w/ null176var funLsh4 = (a, b) => { return a << b; }177warmup(funLsh4, [[5, null, 5], [null, 1, 0], [63, null, 63], [null, 12, 0]]);178//Lsh Boolean w/ undefined179var funLsh5 = (a, b) => { return a << b; }180warmup(funLsh5, [[5, void 0, 5], [void 0, 1, 0], [63, void 0, 63], [void 0, 12, 0]]);181//Rsh Int32182var funRsh1 = (a, b) => { return a >> b; }183warmup(funRsh1, [[1,1,0], [5,1,2], [63,31,0], [4294967295,2147483647,-1], [-2,10,-1],184                 [-15,-2,-1], [4,128,4], [1,10,0], [1024,2,256]]);185//Rsh Int32186var funRsh2 = (a, b) => { return a >> b; }187warmup(funRsh2, [[true,1,0], [1,true,0], [false, 3, 0], [3, false, 3]]);188//Rsh Number Number189var funRsh3 = (a, b) => { return a >> b; }190warmup(funRsh3, [[54772703898, 11, -518492 ], [2147483658, 0, -2147483638]]);191//Rsh Int32 null192var funRsh4 = (a, b) => { return a >> b; }193warmup(funRsh4, [[null, 1, 0], [1, null, 1], [null, 3, 0], [3, null, 3]]);194//Rsh Int32 undefined195var funRsh5 = (a, b) => { return a >> b; }196warmup(funRsh5, [[void 0, 1, 0], [1, void 0, 1], [void 0, 3, 0], [3, void 0, 3]]);197//URsh Int32198var funURsh1 = (a, b) => { return a >>> b; }199warmup(funURsh1, [[1,1,0], [5,1,2], [63,31,0], [4294967295,2147483647,1], [-2,10,4194303],200                  [-15,-2,3], [4,128,4], [1,10,0], [1024,2,256], [0, -6, 0], [0, 6, 0],201                  [0x55005500, 2, 0x15401540]]);202//URsh Boolean Int32203var funURsh2 = (a, b) => { return a >>> b; }204warmup(funURsh2, [[true,1,0], [5,true,2], [63,false,63], [false, 20, 0]]);205//URsh Int32206var funURsh3 = (a, b) => { return a >>> b; }207warmup(funURsh3, [[4294967295, 0, 4294967295]]);208//URsh Number Number209var funURsh4 = (a, b) => { return a >>> b; }210warmup(funURsh4, [[54772703898, 11, 1578660], [2147483658, 11, 1048576],211                  [4294967295, 0, 4294967295]]);212//URsh null Int32213var funURsh5 = (a, b) => { return a >>> b; }214warmup(funURsh5, [[null, 1, 0], [5, null, 5], [63, null, 63], [null, 20, 0]]);215//URsh undefined Int32216var funURsh6 = (a, b) => { return a >>> b; }217warmup(funURsh6, [[void 0, 1, 0], [5, void 0, 5], [63, void 0, 63], [void 0, 20, 0]]);218// Other Test cases that Have been useful:219for (var k=0; k < 30; k++) {220    A="01234567";221    res =""222    for (var i = 0; i < 8; ++i) {223        var v = A[7 - i];224        res+=v;225    }226    assertEq(res, "76543210");227}228// Begin OOM testing:229if (!('oomTest' in this))230    quit();231// Add: String Number Concat OOM test232var addOom = (a, b) => { return a + b; }233function generate_digits(prefix, start) {234    digits = []235    number = ""+start+".25";236    for (var i = 1; i < 7; i++) {237        number = i + number;238        digits.push([prefix, Number(number), prefix + number]);239    }240    return digits;241}242// Trying to defeat dtoacache: Warm the IC with one set of digits, then actually oomTest243// using another set.244var warmup_digits = generate_digits("x", 1);245var test_digits = generate_digits("x", 2);246function ot(digits) {247    warmup(addOom, digits);248}249// Ensure ICs are warmed250ot(warmup_digits);...test_lr_schedulers.py
Source:test_lr_schedulers.py  
...179                assert full_logs[kwargs['warmup_updates']]['lr'] == 1.0180            return logs_first, logs_second181    def test_invsqrt(self):182        self._test_scheduler(lr_scheduler='invsqrt')183    def test_invsqrt_warmup(self):184        self._test_scheduler(lr_scheduler='invsqrt', warmup_updates=25)185    def test_invsqrt_long_warmup(self):186        self._test_scheduler(lr_scheduler='invsqrt', warmup_updates=self.PREEMPT + 30)187    def test_reduceonplateau(self):188        self._test_scheduler(lr_scheduler='reduceonplateau')189    def test_reduceonplateau_warmup(self):190        self._test_scheduler(lr_scheduler='reduceonplateau', warmup_updates=25)191    def test_reduceonplateau_long_warmup(self):192        self._test_scheduler(193            lr_scheduler='reduceonplateau', warmup_updates=self.PREEMPT + 30194        )195    def test_linear(self):196        self._test_scheduler(lr_scheduler='linear')197    def test_linear_warmup(self):198        self._test_scheduler(lr_scheduler='linear', warmup_updates=25)199    def test_linear_long_warmup(self):200        self._test_scheduler(lr_scheduler='linear', warmup_updates=self.PREEMPT + 30)201    def test_cosine(self):202        self._test_scheduler(lr_scheduler='cosine')203    def test_cosine_warmup(self):204        self._test_scheduler(lr_scheduler='cosine', warmup_updates=25)205    def test_cosine_long_warmup(self):...Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!
