How to use bc method in fast-check-monorepo

Best JavaScript code snippet using fast-check-monorepo

original_card.js

Source:original_card.js Github

copy

Full Screen

...5 };6 }7 function end(me, non_bc, bc) {8 if (bc && non_bc) {9 me.owner.end_bc(me);10 }11 }12 function spell_next_step(me, f) {13 me.owner.g_handler.add_callback(f, me, [me]);14 }15 function end_spell(me) {16 me.owner.end_spell_txt(me);17 }18 // Choose AT MOST n cards. 19 // If n is 1, then it returns an element. If not, it will20 // return ARRAY of chosen cards 21 function rand(arr, n) {22 if (n == 1 || !n) return arr[Math.floor(arr.length * Math.random())];23 var sel = [];...

Full Screen

Full Screen

boluscalc.js

Source:boluscalc.js Github

copy

Full Screen

1'use strict';2var _ = require('lodash');3var moment = require('moment-timezone');4var times = require('../times');5var Storages = require('js-storage');6function init (client, $) {7 var boluscalc = {};8 var translate = client.translate;9 var storage = Storages.localStorage;10 var iob = client.plugins('iob');11 var cob = client.plugins('cob');12 var eventTime = $('#bc_eventTimeValue');13 var eventDate = $('#bc_eventDateValue');14 var quickpicks = [];15 var foods = [];16 var icon_remove = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAACrElEQVQ4T42Ty2sTQRzHv5tmk2yyjRNtpfZhL8V6s2KoUNC2XqwgaCsVQcGiFqpHi0c9iRdR/ANE9KR40FIQX4cueKoPaKFoLdSYNtE0abKT1+5s9iW7aUMiHtzTzO7v85md+c6PA4DrHbsPCKIgOWO1pA7dT6YXnXH949SE/F63pqwZtRrO+SCKgjQ5NUV+azpmHj2krMwaJC4c8Erj+/eRyloMMwWFKgbn1nC3ervlK1evkXBLGBZT8SOewotnTylTNLdgeg/pDgZDC2cPHSR8bB22DVC9hFe0SG/H0xFXcHlykjRHRDBWgJcZSCY38Xx2lhqMnRYE34Px/sN9vlQWeoHBAx2yXsRruVAVuFsIBaSJ8+eJGPaBqQV4NROJjTzez89jLBoFn6FgybQL54wS3uTyVDFQ3cL2IYpBv3RhdJSIIQ80tQyv7gEqJvS8AmUlBs7UXPhtjtZgh3UFNYngk86NHCfNAg9dMwHVBPu+CpsVkTXKeJeVG+AGgTOZ3tt6MSKKjy+NjEBjFrR4ElZmA4pdxstMFsyyJu6tZZ7Ux9vwB6EAL50ZGiRECEPPUOixVTRxHlicgSVWxEdZpuZWfNuS2hk48NjwMIkIYZglBnV5Cbqtws/5IaAJmsfCglrEl2y2QeKmEBJ80tixKmxrFpSVr0gV0viQoxho2YUuPohmeFD22PiklLC4ma5JuBvdrfLJI0dJd0s7bM0ES8aR/BXDXGaTskqlL+D3Lwy0tZEePoAd4EA5YF4tYymdonfjmQh3s6dTPjU4SHYGwjAKecSXFyGlM1TdytntE56T+ts7SC/vhw3gm6njc2Kd3vm5Ub1IwQAvnYhGiZpYw1wiWYPrIw7wnBTt7CLOOwdmut14kQQvqt24tfK/utGR6LaF+iRqMf4N/O/8D28HiiCRYqzAAAAAAElFTkSuQmCC';17 function roundTo (x, step) {18 if (x) {19 return Math.round(x / step) * step;20 }21 return 0;22 }23 function maybePrevent (event) {24 if (event) {25 event.preventDefault();26 }27 }28 function isProfileEnabled (profiles) {29 return client.settings.enable.indexOf('profile') > -1 &&30 client.settings.extendedSettings.profile &&31 client.settings.extendedSettings.profile.multiple &&32 profiles.length > 1;33 }34 function isTouch () {35 try { document.createEvent('TouchEvent'); return true; } catch (e) { return false; }36 }37 function setDateAndTime (time) {38 time = time || moment();39 eventTime.val(time.format('HH:mm'));40 eventDate.val(time.format('YYYY-MM-DD'));41 }42 function mergeDateAndTime () {43 return client.utils.mergeInputTime(eventTime.val(), eventDate.val());44 }45 function updateTime (ele, time) {46 ele.attr('oldminutes', time.minutes());47 ele.attr('oldhours', time.hours());48 }49 function setBG (sgv, selectedTime) {50 var sensorbg = 0;51 boluscalc.oldbg = false;52 if (sgv) {53 sensorbg = sgv.mgdl;54 if (sensorbg < 39) {55 sensorbg = 0;56 } else {57 sensorbg = client.utils.scaleMgdl(sensorbg);58 }59 if (selectedTime.getTime() - sgv.mills > 10 * 60 * 1000) {60 boluscalc.oldbg = true; // Do not use if record is older than 10 min61 sensorbg = 0;62 }63 }64 // Set BG65 if ($('#bc_bgfromsensor').is(':checked')) {66 $('#bc_bg').val(sensorbg ? sensorbg : '');67 }68 }69 boluscalc.updateVisualisations = function updateVisualisations (sbx) {70 // update BG in GUI71 setBG(sbx.lastSGVEntry(), mergeDateAndTime().toDate());72 if (client.browserUtils.getLastOpenedDrawer !== '#boluscalcDrawer') {73 return;74 }75 if ($('#bc_nowtime').is(':checked')) {76 // Update time77 setDateAndTime();78 boluscalc.calculateInsulin();79 }80 };81 boluscalc.dateTimeFocus = function dateTimeFocus (event) {82 $('#bc_othertime').prop('checked', true);83 updateTime($(this), mergeDateAndTime());84 maybePrevent(event);85 };86 boluscalc.dateTimeChange = function dateTimeChange (event) {87 $('#bc_othertime').prop('checked', true);88 // client.utils.setYAxisOffset(50); //50% of extend89 var ele = $(this);90 var merged = mergeDateAndTime();91 if (ele.attr('oldminutes') === '59' && merged.minutes() === 0) {92 merged.add(1, 'hours');93 }94 if (ele.attr('oldminutes') === '0' && merged.minutes() === 59) {95 merged.add(-1, 'hours');96 }97 setDateAndTime(merged);98 updateTime(ele, merged);99 boluscalc.eventTimeTypeChange();100 // update BG from sgv to this time101 setBG(findClosestSGVToPastTime(merged.toDate()), merged.toDate());102 boluscalc.calculateInsulin();103 maybePrevent(event);104 // Nightscout.utils.updateBrushToTime(moment.toDate());105 };106 boluscalc.eventTimeTypeChange = function eventTimeTypeChange (event) {107 if ($('#bc_othertime').is(':checked')) {108 $('#bc_eventTimeValue').focus();109 $('#bc_retro').css('display', '');110 if (mergeDateAndTime() < moment()) {111 $('#bc_retro').css('background-color', 'red').text(translate('RETRO MODE'));112 } else if (mergeDateAndTime() > moment()) {113 $('#bc_retro').css('background-color', 'blue').text(translate('IN THE FUTURE'));114 } else {115 $('#bc_retro').css('display', 'none');116 }117 } else {118 $('#bc_retro').css('display', 'none');119 setDateAndTime();120 boluscalc.updateVisualisations(client.sbx);121 if (event) {122 boluscalc.calculateInsulin();123 }124 // Nightscout.utils.setYAxisOffset(50); //50% of extend125 // Nightscout.utils.updateBrushToTime(Nightscout.utils.mergeInputTime($('#bc_eventTimeValue').val(), $('#bc_eventDateValue').val()).toDate());126 }127 maybePrevent(event);128 };129 boluscalc.toggleDrawer = function toggleDrawer (event) {130 boluscalc.prepare();131 client.browserUtils.toggleDrawer('#boluscalcDrawer');132 maybePrevent(event);133 };134 boluscalc.prepare = function prepare () {135 foods = [];136 $('#bc_profile').empty();137 var profiles = client.profilefunctions.listBasalProfiles();138 profiles.forEach(function(p) {139 $('#bc_profile').append('<option val="' + p + '">' + p + '</option>');140 });141 $('#bc_profileLabel').toggle(isProfileEnabled(profiles));142 $('#bc_usebg').prop('checked', 'checked');143 $('#bc_usecarbs').prop('checked', 'checked');144 $('#bc_usecob').prop('checked', '');145 $('#bc_useiob').prop('checked', 'checked');146 $('#bc_bgfromsensor').prop('checked', 'checked');147 $('#bc_carbs').val('');148 $('#bc_quickpick').val(-1);149 $('#bc_preBolus').val(0);150 $('#bc_notes').val('');151 $('#bc_enteredBy').val(Storages.localStorage.get('enteredBy') || '');152 $('#bc_nowtime').prop('checked', true);153 $('#bc_othercorrection').val(0);154 $('#bc_profile').val(client.profilefunctions.activeProfileToTime());155 setDateAndTime();156 boluscalc.eventTimeTypeChange();157 boluscalc.updateVisualisations(client.sbx);158 boluscalc.calculateInsulin();159 };160 boluscalc.calculateInsulin = function calculateInsulin (event) {161 maybePrevent(event);162 boluscalc.gatherBoluscalcData();163 boluscalc.updateGui(boluscalc.record);164 return boluscalc.record;165 };166 boluscalc.updateGui = function updateGui (record) {167 record = record || boluscalc.record;168 if (record.eventTime === undefined) {169 return;170 }171 var targetBGLow = record.targetBGLow;172 var targetBGHigh = record.targetBGHigh;173 var isf = record.isf;174 var ic = record.ic;175 // Clear results before calculation176 $('#bc_insulintotal').text('0.00');177 $('#bc_carbsneeded').text('0.00');178 $('#bc_inzulinbg').text('0.00');179 $('#bc_inzulincarbs').text('0.00');180 // Show IOB181 if ($('#bc_useiob').is(':checked')) {182 $('#bc_iob').text((record.iob > 0 ? '-' : '') + record.iob.toFixed(2));183 } else {184 $('#bc_iob').text('');185 }186 // Show COB187 if ($('#bc_usecob').is(':checked')) {188 $('#bc_cob').text(record.cob.toFixed(2));189 $('#bc_cobu').text(record.insulincob.toFixed(2));190 } else {191 $('#bc_cob').text('');192 $('#bc_cobu').text('');193 }194 // Show BG195 if ($('#bc_usebg').is(':checked')) {196 if (record.bg === 0 || (boluscalc.oldbg && $('#bc_bgfromsensor').is(':checked'))) {197 $('#bc_bg').css('background-color', 'red');198 } else {199 $('#bc_bg').css('background-color', '');200 }201 $('#bc_inzulinbg').text(record.insulinbg.toFixed(2));202 $('#bc_inzulinbg').attr('title'203 , 'Target BG range: ' + targetBGLow + ' - ' + targetBGHigh +204 '\nISF: ' + isf +205 '\nBG diff: ' + record.bgdiff.toFixed(1)206 );207 } else {208 $('#bc_inzulinbgtd').css('background-color', '');209 $('#bc_bg').css('background-color', '');210 $('#bc_inzulinbg').text('');211 $('#bc_inzulinbg').attr('title', '');212 }213 // Show foods214 if (record.foods.length) {215 var html = '<table style="float:right;margin-right:20px;font-size:12px">';216 var carbs = 0;217 for (var fi = 0; fi < record.foods.length; fi++) {218 /* eslint-disable-next-line security/detect-object-injection */ // verified false positive219 var f = record.foods[fi];220 carbs += f.carbs * f.portions;221 html += '<tr>';222 html += '<td>';223 if ($('#bc_quickpick').val() < 0) { // do not allow deleting while quickpick active224 html += '<img style="cursor:pointer" title="Delete record" src="' + icon_remove + '" href="#" class="deleteFoodRecord" index="' + fi + '">';225 }226 html += '</td>';227 html += '<td>' + f.name + '</td>';228 html += '<td>' + (f.portion * f.portions).toFixed(1) + ' ' + translate(f.unit) + '</td>';229 html += '<td>(' + (f.carbs * f.portions).toFixed(1) + ' g)</td>';230 html += '</tr>';231 }232 html += '</table>';233 $('#bc_food').html(html);234 $('.deleteFoodRecord').click(deleteFoodRecord);235 $('#bc_carbs').val(carbs.toFixed(0));236 $('#bc_carbs').attr('disabled', true);237 $('#bc_gi').css('display', 'none');238 $('#bc_gicalculated').css('display', '');239 $('#bc_gicalculated').text(record.gi);240 } else {241 $('#bc_food').html('');242 $('#bc_carbs').attr('disabled', false);243 $('#bc_gi').css('display', '');244 $('#bc_gicalculated').css('display', 'none');245 $('#bc_gicalculated').text('');246 }247 // Show Carbs248 if ($('#bc_usecarbs').is(':checked')) {249 if ($('#bc_carbs').val() === '') {250 $('#bc_carbs').css('background-color', '');251 } else if (isNaN(parseInt($('#bc_carbs').val().replace(',', '.')))) {252 $('#bc_carbs').css('background-color', 'red');253 } else {254 $('#bc_carbs').css('background-color', '');255 }256 $('#bc_inzulincarbs').text(record.insulincarbs.toFixed(2));257 $('#bc_inzulincarbs').attr('title', 'IC: ' + ic);258 } else {259 $('#bc_carbs').css('background-color', '');260 $('#bc_inzulincarbs').text('');261 $('#bc_inzulincarbs').attr('title', '');262 $('#bc_carbs').text('');263 }264 // Show Total265 $('#bc_rouding').text(record.roundingcorrection.toFixed(2));266 $('#bc_insulintotal').text(record.insulin.toFixed(2));267 // Carbs needed if too much iob or in range message when nothing entered and in range268 var outcome = record.bg - record.iob * isf;269 if (record.othercorrection === 0 && record.carbs === 0 && record.cob === 0 && record.bg > 0 && outcome > targetBGLow && outcome < targetBGHigh) {270 $('#bc_carbsneeded').text('');271 $('#bc_insulinover').text('');272 $('#bc_carbsneededtr').css('display', 'none');273 $('#bc_insulinneededtr').css('display', 'none');274 $('#bc_calculationintarget').css('display', '');275 } else if (record.insulin < 0) {276 $('#bc_carbsneeded').text(record.carbsneeded + ' g');277 $('#bc_insulinover').text(record.insulin.toFixed(2));278 $('#bc_carbsneededtr').css('display', '');279 $('#bc_insulinneededtr').css('display', 'none');280 $('#bc_calculationintarget').css('display', 'none');281 } else {282 $('#bc_carbsneeded').text('');283 $('#bc_insulinover').text('');284 $('#bc_carbsneededtr').css('display', 'none');285 $('#bc_insulinneededtr').css('display', '');286 $('#bc_calculationintarget').css('display', 'none');287 }288 // Show basal rate289 var basal = client.sbx.data.profile.getTempBasal(record.eventTime);290 var tempMark = '';291 tempMark += basal.treatment ? 'T' : '';292 tempMark += basal.combobolustreatment ? 'C' : '';293 tempMark += tempMark ? ': ' : '';294 $('#bc_basal').text(tempMark + basal.totalbasal.toFixed(3));295 };296 boluscalc.gatherBoluscalcData = function gatherBoluscalcData () {297 boluscalc.record = {};298 var record = boluscalc.record;299 if (!client.sbx) {300 console.log('No sandbox data yet. Exiting gatherBoluscalcData()');301 return;302 }303 record.profile = $('#bc_profile').val();304 if (!record.profile) {305 delete record.profile;306 console.log('No profile data. Exiting gatherBoluscalcData()');307 return;308 }309 // Calculate event time from date & time310 record.eventTime = new Date();311 if ($('#bc_othertime').is(':checked')) {312 record.eventTime = mergeDateAndTime().toDate();313 }314 // Load profile315 var targetBGLow = client.sbx.data.profile.getLowBGTarget(record.eventTime, record.profile);316 targetBGLow = targetBGLow || 0;317 var targetBGHigh = client.sbx.data.profile.getHighBGTarget(record.eventTime, record.profile);318 targetBGHigh = targetBGHigh || 0;319 var isf = client.sbx.data.profile.getSensitivity(record.eventTime, record.profile);320 isf = isf || 0;321 var ic = client.sbx.data.profile.getCarbRatio(record.eventTime, record.profile);322 ic = ic || 0;323 record.targetBGLow = targetBGLow;324 record.targetBGHigh = targetBGHigh;325 record.isf = isf;326 record.ic = ic;327 if (targetBGLow === 0 || targetBGHigh === 0 || isf === 0 || ic === 0) {328 $('#bc_inzulinbgtd').css('background-color', 'red');329 boluscalc.record = {};330 return;331 } else {332 $('#bc_inzulinbgtd').css('background-color', '');333 }334 if (ic === 0) {335 $('#bc_inzulincarbstd').css('background-color', 'red');336 boluscalc.record = {};337 return;338 } else {339 $('#bc_inzulincarbstd').css('background-color', '');340 }341 // Load IOB342 record.iob = 0;343 if ($('#bc_useiob').is(':checked')) {344 record.iob = roundTo(iob.calcTotal(client.sbx.data.treatments, client.sbx.data.devicestatus, client.sbx.data.profile, record.eventTime, record.profile).iob, 0.01);345 }346 // Load COB347 record.cob = 0;348 record.insulincob = 0;349 if ($('#bc_usecob').is(':checked')) {350 record.cob = roundTo(cob.cobTotal(client.sbx.data.treatments, client.sbx.data.devicestatus, client.sbx.data.profile, record.eventTime, record.profile).cob, 0.01);351 record.insulincob = roundTo(record.cob / ic, 0.01);352 }353 // Load BG354 record.bg = 0;355 record.insulinbg = 0;356 record.bgdiff = 0;357 if ($('#bc_usebg').is(':checked')) {358 record.bg = parseFloat($('#bc_bg').val().replace(',', '.'));359 if (isNaN(record.bg)) {360 record.bg = 0;361 }362 if (record.bg <= targetBGLow) {363 record.bgdiff = record.bg - targetBGLow;364 } else if (record.bg >= targetBGHigh) {365 record.bgdiff = record.bg - targetBGHigh;366 }367 record.bgdiff = roundTo(record.bgdiff, 0.1);368 if (record.bg !== 0) {369 record.insulinbg = roundTo(record.bgdiff / isf, 0.01);370 }371 }372 // Load foods373 record.carbs = 0;374 record.foods = _.cloneDeep(foods);375 if (record.foods.length) {376 var gisum = 0;377 for (var fi = 0; fi < record.foods.length; fi++) {378 /* eslint-disable-next-line security/detect-object-injection */ // verified false positive379 var f = record.foods[fi];380 record.carbs += f.carbs * f.portions;381 gisum += f.carbs * f.portions * f.gi;382 }383 record.gi = (gisum / record.carbs).toFixed(2);384 } else {385 record.gi = $('#bc_gi').val();386 }387 // Load Carbs388 record.insulincarbs = 0;389 if ($('#bc_usecarbs').is(':checked')) {390 if (record.carbs === 0) { // not set from foods391 record.carbs = parseInt($('#bc_carbs').val().replace(',', '.'));392 }393 if (isNaN(record.carbs)) {394 record.carbs = 0;395 }396 record.insulincarbs = roundTo(record.carbs / ic, 0.01);397 }398 // Corrections399 record.othercorrection = parseFloat($('#bc_othercorrection').val());400 // Total & rounding401 var total = 0;402 if ($('#bc_useinsulin').is(':checked')) {403 total = record.insulinbg + record.insulincarbs + record.insulincob - record.iob + record.othercorrection;404 }405 record.insulin = roundTo(total, 0.05);406 record.roundingcorrection = record.insulin - total;407 // Carbs needed if too much iob408 record.carbsneeded = 0;409 if (record.insulin < 0) {410 record.carbsneeded = Math.ceil(-total * ic);411 }412 console.log('Insulin calculation result: ', record);413 return record;414 };415 function gatherData () {416 var data = {};417 data.boluscalc = boluscalc.calculateInsulin();418 if (!data.boluscalc) {419 alert('Calculation not completed!');420 return null;421 }422 data.enteredBy = $('#bc_enteredBy').val();423 data.eventType = 'Bolus Wizard';424 if ($('#bc_bg').val() !== 0) {425 data.glucose = $('#bc_bg').val().replace(',', '.');426 data.glucoseType = $('#boluscalc-form').find('input[name=bc_bginput]:checked').val();427 data.units = client.settings.units;428 }429 data.carbs = $('#bc_carbs').val().replace(',', '.');430 data.insulin = $('#bc_insulintotal').text();431 if (data.insulin <= 0) {432 delete data.insulin;433 }434 data.preBolus = parseInt($('#bc_preBolus').val());435 data.notes = $('#bc_notes').val();436 if ($('#bc_othertime').is(':checked')) {437 data.eventTime = mergeDateAndTime().toDate();438 }439 // replace boluscalc.eventTime by ISO string440 data.boluscalc.eventTime = data.boluscalc.eventTime.toISOString();441 return data;442 }443 boluscalc.submit = function submit (event) {444 var data = gatherData();445 if (data) {446 confirmPost(data);447 }448 maybePrevent(event);449 return false;450 };451 function buildConfirmText (data) {452 var text = [453 translate('Please verify that the data entered is correct') + ': '454 455 , translate('Event Type') + ': ' + translate(data.eventType)456 ];457 function pushIf (check, valueText) {458 if (check) {459 text.push(valueText);460 }461 }462 pushIf(data.glucose, translate('Blood Glucose') + ': ' + data.glucose);463 pushIf(data.glucose, translate('Measurement Method') + ': ' + translate(data.glucoseType));464 pushIf(data.carbs, translate('Carbs Given') + ': ' + data.carbs);465 pushIf(data.insulin, translate('Insulin Given') + ': ' + data.insulin);466 pushIf(data.boluscalc.othercorrection, translate('Other correction') + ': ' + data.boluscalc.othercorrection);467 pushIf(data.preBolus, translate('Carb Time') + ': ' + data.preBolus + ' ' + translate('mins'));468 pushIf(data.notes, translate('Notes') + ': ' + data.notes);469 pushIf(data.enteredBy, translate('Entered By') + ': ' + data.enteredBy);470 text.push(translate('Event Time') + ': ' + (data.eventTime ? data.eventTime.toLocaleString() : new Date().toLocaleString()));471 return text.join('\n');472 }473 function confirmPost (data) {474 if (window.confirm(buildConfirmText(data))) {475 $.ajax({476 method: 'POST'477 , url: '/api/v1/treatments/'478 , headers: client.headers()479 , data: data480 }).done(function treatmentSaved (response) {481 console.info('treatment saved', response);482 }).fail(function treatmentSaveFail (response) {483 console.info('treatment saved', response);484 alert(translate('Entering record failed') + '. ' + translate('Status') + ': ' + response.status);485 });486 storage.set('enteredBy', data.enteredBy);487 quickpickHideFood();488 client.browserUtils.closeDrawer('#boluscalcDrawer');489 }490 }491 // Food manipulation492 function deleteFoodRecord (event) {493 var index = $(this).attr('index');494 foods.splice(index, 1);495 $('#bc_carbs').val('');496 boluscalc.calculateInsulin();497 maybePrevent(event);498 return false;499 }500 function quickpickChange (event) {501 var qpiselected = $('#bc_quickpick').val();502 if (qpiselected === null || qpiselected === '-1') { // (none)503 $('#bc_carbs').val(0);504 foods = [];505 $('#bc_addfoodarea').css('display', '');506 } else {507 var qp = quickpicks[parseInt(qpiselected)];508 foods = _.cloneDeep(qp.foods);509 $('#bc_addfoodarea').css('display', 'none');510 }511 boluscalc.calculateInsulin();512 maybePrevent(event);513 }514 function quickpickHideFood () {515 var qpiselected = $('#bc_quickpick').val();516 if (qpiselected >= 0) {517 var qp = quickpicks[parseInt(qpiselected)];518 if (qp.hideafteruse) {519 qp.hidden = true;520 $.ajax({521 method: 'PUT'522 , url: '/api/v1/food/'523 , headers: client.headers()524 , data: qp525 }).done(function treatmentSaved (response) {526 console.info('quick pick saved', response);527 }).fail(function treatmentSaveFail (response) {528 console.info('quick pick failed to save', response);529 });530 }531 }532 boluscalc.calculateInsulin();533 maybePrevent(event);534 }535 var categories = [];536 var foodlist = [];537 var databaseloaded = false;538 var filter = {539 category: ''540 , subcategory: ''541 , name: ''542 };543 boluscalc.loadFoodDatabase = function loadFoodDatabase (event, callback) {544 categories = [];545 foodlist = [];546 var records = client.sbx.data.food || [];547 records.forEach(function(r) {548 if (r.type == 'food') {549 foodlist.push(r);550 if (r.category && !categories[r.category]) {551 categories[r.category] = {};552 }553 if (r.category && r.subcategory) {554 categories[r.category][r.subcategory] = true;555 }556 }557 });558 databaseloaded = true;559 console.log('Food database loaded');560 fillForm();561 maybePrevent(event);562 if (callback) { callback(); }563 };564 boluscalc.loadFoodQuickpicks = function loadFoodQuickpicks () {565 // Load quickpicks566 quickpicks = [];567 var records = client.sbx.data.food || [];568 records.forEach(function(r) {569 if (r.type == 'quickpick') {570 quickpicks.push(r);571 }572 });573 $('#bc_quickpick').empty().append('<option value="-1">' + translate('(none)') + '</option>');574 for (var i = 0; i < records.length; i++) {575 /* eslint-disable-next-line security/detect-object-injection */ // verified false positive576 var r = records[i];577 $('#bc_quickpick').append('<option value="' + i + '">' + r.name + ' (' + r.carbs + ' g)</option>');578 }579 $('#bc_quickpick').val(-1);580 $('#bc_quickpick').change(quickpickChange);581 };582 function fillForm (event) {583 $('#bc_filter_category').empty().append('<option value="">' + translate('(none)') + '</option>');584 Object.keys(categories).forEach(function eachCategory (s) {585 $('#bc_filter_category').append('<option value="' + s + '">' + s + '</option>');586 });587 filter.category = '';588 fillSubcategories();589 $('#bc_filter_category').change(fillSubcategories);590 $('#bc_filter_subcategory').change(doFilter);591 $('#bc_filter_name').on('input', doFilter);592 maybePrevent(event);593 return false;594 }595 function fillSubcategories (event) {596 maybePrevent(event);597 filter.category = $('#bc_filter_category').val();598 filter.subcategory = '';599 $('#bc_filter_subcategory').empty().append('<option value="">' + translate('(none)') + '</option>');600 if (filter.category !== '') {601 Object.keys(categories[filter.category]).forEach(function eachSubcategory (s) {602 $('#bc_filter_subcategory').append('<option value="' + s + '">' + s + '</option>');603 });604 }605 doFilter();606 }607 function doFilter (event) {608 if (event) {609 filter.category = $('#bc_filter_category').val();610 filter.subcategory = $('#bc_filter_subcategory').val();611 filter.name = $('#bc_filter_name').val();612 }613 $('#bc_data').empty();614 for (var i = 0; i < foodlist.length; i++) {615 /* eslint-disable security/detect-object-injection */ // verified false positive616 if (filter.category !== '' && foodlist[i].category !== filter.category) { continue; }617 if (filter.subcategory !== '' && foodlist[i].subcategory !== filter.subcategory) { continue; }618 if (filter.name !== '' && foodlist[i].name.toLowerCase().indexOf(filter.name.toLowerCase()) < 0) { continue; }619 var o = '';620 o += foodlist[i].name + ' | ';621 o += 'Portion: ' + foodlist[i].portion + ' ';622 o += foodlist[i].unit + ' | ';623 o += 'Carbs: ' + foodlist[i].carbs + ' g';624 $('#bc_data').append('<option value="' + i + '">' + o + '</option>');625 /* eslint-enable security/detect-object-injection */ // verified false positive626 }627 $('#bc_addportions').val('1');628 maybePrevent(event);629 }630 function addFoodFromDatabase (event) {631 if (!databaseloaded) {632 boluscalc.loadFoodDatabase(event, addFoodFromDatabase);633 return;634 }635 $('#bc_addportions').val('1');636 $('#bc_addfooddialog').dialog({637 width: 640638 , height: 400639 , buttons: [640 {641 text: translate('Add')642 , click: function() {643 var index = $('#bc_data').val();644 var portions = parseFloat($('#bc_addportions').val().replace(',', '.'));645 if (index !== null && !isNaN(portions) && portions > 0) {646 index = parseInt(index);647 /* eslint-disable security/detect-object-injection */ // verified false positive648 foodlist[index].portions = portions;649 foods.push(_.cloneDeep(foodlist[index]));650 /* eslint-enable security/detect-object-injection */ // verified false positive651 $(this).dialog('close');652 boluscalc.calculateInsulin();653 }654 }655 }656 , {657 text: translate('Reload database')658 , class: 'leftButton'659 , click: boluscalc.loadFoodDatabase660 }661 ]662 , open: function() {663 $(this).parent().css('box-shadow', '20px 20px 20px 0px black');664 $(this).parent().find('.ui-dialog-buttonset').css({ 'width': '100%', 'text-align': 'right' });665 $(this).parent().find('button:contains("' + translate('Add') + '")').css({ 'float': 'left' });666 $('#bc_filter_name').focus();667 }668 });669 maybePrevent(event);670 return false;671 }672 function findClosestSGVToPastTime (time) {673 var nowData = client.entries.filter(function(d) {674 return d.type === 'sgv' && d.mills <= time.getTime();675 });676 var focusPoint = _.last(nowData);677 if (!focusPoint || focusPoint.mills + times.mins(10).mills < time.getTime()) {678 return null;679 }680 return focusPoint;681 }682 if (isTouch()) {683 // Make it faster on mobile devices684 $('.insulincalculationpart').change(boluscalc.calculateInsulin);685 } else {686 $('.insulincalculationpart').on('input', boluscalc.calculateInsulin);687 $('input:checkbox.insulincalculationpart').change(boluscalc.calculateInsulin);688 }689 $('#bc_bgfrommeter').change(boluscalc.calculateInsulin);690 $('#bc_addfromdatabase').click(addFoodFromDatabase);691 $('#bc_bgfromsensor').change(function bc_bgfromsensor_click (event) {692 boluscalc.updateVisualisations(client.sbx);693 boluscalc.calculateInsulin();694 maybePrevent(event);695 });696 $('#boluscalcDrawerToggle').click(boluscalc.toggleDrawer);697 $('#boluscalcDrawer').find('button').click(boluscalc.submit);698 $('#bc_eventTime input:radio').change(boluscalc.eventTimeTypeChange);699 $('.bc_eventtimeinput').focus(boluscalc.dateTimeFocus).change(boluscalc.dateTimeChange);700 boluscalc.loadFoodQuickpicks();701 setDateAndTime();702 return boluscalc;703}...

Full Screen

Full Screen

test_cert_version.js

Source:test_cert_version.js Github

copy

Full Screen

1// -*- indent-tabs-mode: nil; js-indent-level: 2 -*-2// This Source Code Form is subject to the terms of the Mozilla Public3// License, v. 2.0. If a copy of the MPL was not distributed with this4// file, You can obtain one at http://mozilla.org/MPL/2.0/.5// Tests the interaction between the basic constraints extension and the6// certificate version field. In general, the testcases consist of verifying7// certificate chains of the form:8//9// end-entity (issued by) intermediate (issued by) trusted X509v3 root10//11// where the intermediate is one of X509 v1, v2, v3, or v4, and either does or12// does not have the basic constraints extension. If it has the extension, it13// either does or does not specify that it is a CA.14//15// To test cases where the trust anchor has a different version and/or does or16// does not have the basic constraint extension, there are testcases where the17// intermediate is trusted as an anchor and the verification is repeated.18// (Loading a certificate with trust "CTu,," means that it is a trust anchor19// for SSL. Loading a certificate with trust ",," means that it inherits its20// trust.)21//22// There are also testcases for end-entities issued by a trusted X509v3 root23// where the end-entities similarly cover the range of versions and basic24// constraint extensions.25//26// Finally, there are testcases for self-signed certificates that, again, cover27// the range of versions and basic constraint extensions.28"use strict";29do_get_profile(); // must be called before getting nsIX509CertDB30const certdb = Cc["@mozilla.org/security/x509certdb;1"]31 .getService(Ci.nsIX509CertDB);32function certFromFile(certName) {33 return constructCertFromFile("test_cert_version/" + certName + ".pem");34}35function loadCertWithTrust(certName, trustString) {36 addCertFromFile(certdb, "test_cert_version/" + certName + ".pem", trustString);37}38function checkEndEntity(cert, expectedResult) {39 checkCertErrorGeneric(certdb, cert, expectedResult, certificateUsageSSLServer);40}41function checkIntermediate(cert, expectedResult) {42 checkCertErrorGeneric(certdb, cert, expectedResult, certificateUsageSSLCA);43}44// Test that the code that decodes certificates to display them in the45// certificate manager correctly handles the version field.46function checkCertVersion(cert, expectedVersionString) {47 let asn1 = cert.ASN1Structure.QueryInterface(Ci.nsIASN1Sequence);48 let tbsCertificate = asn1.ASN1Objects.queryElementAt(0, Ci.nsIASN1Sequence);49 let version = tbsCertificate.ASN1Objects.queryElementAt(0, Ci.nsIASN1Object);50 equal(version.displayValue, expectedVersionString,51 "Actual and expected version strings should match");52}53function run_test() {54 loadCertWithTrust("ca", "CTu,,");55 // Section for CAs lacking the basicConstraints extension entirely:56 loadCertWithTrust("int-v1-noBC_ca", ",,");57 checkIntermediate(certFromFile("int-v1-noBC_ca"), MOZILLA_PKIX_ERROR_V1_CERT_USED_AS_CA);58 checkEndEntity(certFromFile("ee_int-v1-noBC"), MOZILLA_PKIX_ERROR_V1_CERT_USED_AS_CA);59 // A v1 certificate with no basicConstraints extension may issue certificates60 // if it is a trust anchor.61 loadCertWithTrust("int-v1-noBC_ca", "CTu,,");62 checkIntermediate(certFromFile("int-v1-noBC_ca"), PRErrorCodeSuccess);63 checkEndEntity(certFromFile("ee_int-v1-noBC"), PRErrorCodeSuccess);64 loadCertWithTrust("int-v2-noBC_ca", ",,");65 checkIntermediate(certFromFile("int-v2-noBC_ca"), SEC_ERROR_CA_CERT_INVALID);66 checkEndEntity(certFromFile("ee_int-v2-noBC"), SEC_ERROR_CA_CERT_INVALID);67 loadCertWithTrust("int-v2-noBC_ca", "CTu,,");68 checkIntermediate(certFromFile("int-v2-noBC_ca"), SEC_ERROR_CA_CERT_INVALID);69 checkEndEntity(certFromFile("ee_int-v2-noBC"), SEC_ERROR_CA_CERT_INVALID);70 loadCertWithTrust("int-v3-noBC_ca", ",,");71 checkIntermediate(certFromFile("int-v3-noBC_ca"), SEC_ERROR_CA_CERT_INVALID);72 checkEndEntity(certFromFile("ee_int-v3-noBC"), SEC_ERROR_CA_CERT_INVALID);73 loadCertWithTrust("int-v3-noBC_ca", "CTu,,");74 checkIntermediate(certFromFile("int-v3-noBC_ca"), SEC_ERROR_CA_CERT_INVALID);75 checkEndEntity(certFromFile("ee_int-v3-noBC"), SEC_ERROR_CA_CERT_INVALID);76 loadCertWithTrust("int-v4-noBC_ca", ",,");77 checkIntermediate(certFromFile("int-v4-noBC_ca"), SEC_ERROR_CA_CERT_INVALID);78 checkEndEntity(certFromFile("ee_int-v4-noBC"), SEC_ERROR_CA_CERT_INVALID);79 loadCertWithTrust("int-v4-noBC_ca", "CTu,,");80 checkIntermediate(certFromFile("int-v4-noBC_ca"), SEC_ERROR_CA_CERT_INVALID);81 checkEndEntity(certFromFile("ee_int-v4-noBC"), SEC_ERROR_CA_CERT_INVALID);82 // Section for CAs with basicConstraints not specifying cA:83 loadCertWithTrust("int-v1-BC-not-cA_ca", ",,");84 checkIntermediate(certFromFile("int-v1-BC-not-cA_ca"), SEC_ERROR_CA_CERT_INVALID);85 checkEndEntity(certFromFile("ee_int-v1-BC-not-cA"), SEC_ERROR_CA_CERT_INVALID);86 loadCertWithTrust("int-v1-BC-not-cA_ca", "CTu,,");87 checkIntermediate(certFromFile("int-v1-BC-not-cA_ca"), SEC_ERROR_CA_CERT_INVALID);88 checkEndEntity(certFromFile("ee_int-v1-BC-not-cA"), SEC_ERROR_CA_CERT_INVALID);89 loadCertWithTrust("int-v2-BC-not-cA_ca", ",,");90 checkIntermediate(certFromFile("int-v2-BC-not-cA_ca"), SEC_ERROR_CA_CERT_INVALID);91 checkEndEntity(certFromFile("ee_int-v2-BC-not-cA"), SEC_ERROR_CA_CERT_INVALID);92 loadCertWithTrust("int-v2-BC-not-cA_ca", "CTu,,");93 checkIntermediate(certFromFile("int-v2-BC-not-cA_ca"), SEC_ERROR_CA_CERT_INVALID);94 checkEndEntity(certFromFile("ee_int-v2-BC-not-cA"), SEC_ERROR_CA_CERT_INVALID);95 loadCertWithTrust("int-v3-BC-not-cA_ca", ",,");96 checkIntermediate(certFromFile("int-v3-BC-not-cA_ca"), SEC_ERROR_CA_CERT_INVALID);97 checkEndEntity(certFromFile("ee_int-v3-BC-not-cA"), SEC_ERROR_CA_CERT_INVALID);98 loadCertWithTrust("int-v3-BC-not-cA_ca", "CTu,,");99 checkIntermediate(certFromFile("int-v3-BC-not-cA_ca"), SEC_ERROR_CA_CERT_INVALID);100 checkEndEntity(certFromFile("ee_int-v3-BC-not-cA"), SEC_ERROR_CA_CERT_INVALID);101 loadCertWithTrust("int-v4-BC-not-cA_ca", ",,");102 checkIntermediate(certFromFile("int-v4-BC-not-cA_ca"), SEC_ERROR_CA_CERT_INVALID);103 checkEndEntity(certFromFile("ee_int-v4-BC-not-cA"), SEC_ERROR_CA_CERT_INVALID);104 loadCertWithTrust("int-v4-BC-not-cA_ca", "CTu,,");105 checkIntermediate(certFromFile("int-v4-BC-not-cA_ca"), SEC_ERROR_CA_CERT_INVALID);106 checkEndEntity(certFromFile("ee_int-v4-BC-not-cA"), SEC_ERROR_CA_CERT_INVALID);107 // Section for CAs with basicConstraints specifying cA:108 loadCertWithTrust("int-v1-BC-cA_ca", ",,");109 checkIntermediate(certFromFile("int-v1-BC-cA_ca"), PRErrorCodeSuccess);110 checkEndEntity(certFromFile("ee_int-v1-BC-cA"), PRErrorCodeSuccess);111 loadCertWithTrust("int-v1-BC-cA_ca", "CTu,,");112 checkIntermediate(certFromFile("int-v1-BC-cA_ca"), PRErrorCodeSuccess);113 checkEndEntity(certFromFile("ee_int-v1-BC-cA"), PRErrorCodeSuccess);114 loadCertWithTrust("int-v2-BC-cA_ca", ",,");115 checkIntermediate(certFromFile("int-v2-BC-cA_ca"), PRErrorCodeSuccess);116 checkEndEntity(certFromFile("ee_int-v2-BC-cA"), PRErrorCodeSuccess);117 loadCertWithTrust("int-v2-BC-cA_ca", "CTu,,");118 checkIntermediate(certFromFile("int-v2-BC-cA_ca"), PRErrorCodeSuccess);119 checkEndEntity(certFromFile("ee_int-v2-BC-cA"), PRErrorCodeSuccess);120 loadCertWithTrust("int-v3-BC-cA_ca", ",,");121 checkIntermediate(certFromFile("int-v3-BC-cA_ca"), PRErrorCodeSuccess);122 checkEndEntity(certFromFile("ee_int-v3-BC-cA"), PRErrorCodeSuccess);123 loadCertWithTrust("int-v3-BC-cA_ca", "CTu,,");124 checkIntermediate(certFromFile("int-v3-BC-cA_ca"), PRErrorCodeSuccess);125 checkEndEntity(certFromFile("ee_int-v3-BC-cA"), PRErrorCodeSuccess);126 loadCertWithTrust("int-v4-BC-cA_ca", ",,");127 checkIntermediate(certFromFile("int-v4-BC-cA_ca"), PRErrorCodeSuccess);128 checkEndEntity(certFromFile("ee_int-v4-BC-cA"), PRErrorCodeSuccess);129 loadCertWithTrust("int-v4-BC-cA_ca", "CTu,,");130 checkIntermediate(certFromFile("int-v4-BC-cA_ca"), PRErrorCodeSuccess);131 checkEndEntity(certFromFile("ee_int-v4-BC-cA"), PRErrorCodeSuccess);132 // Section for end-entity certificates with various basicConstraints:133 checkEndEntity(certFromFile("ee-v1-noBC_ca"), PRErrorCodeSuccess);134 checkEndEntity(certFromFile("ee-v2-noBC_ca"), PRErrorCodeSuccess);135 checkEndEntity(certFromFile("ee-v3-noBC_ca"), PRErrorCodeSuccess);136 checkEndEntity(certFromFile("ee-v4-noBC_ca"), PRErrorCodeSuccess);137 checkEndEntity(certFromFile("ee-v1-BC-not-cA_ca"), PRErrorCodeSuccess);138 checkEndEntity(certFromFile("ee-v2-BC-not-cA_ca"), PRErrorCodeSuccess);139 checkEndEntity(certFromFile("ee-v3-BC-not-cA_ca"), PRErrorCodeSuccess);140 checkEndEntity(certFromFile("ee-v4-BC-not-cA_ca"), PRErrorCodeSuccess);141 checkEndEntity(certFromFile("ee-v1-BC-cA_ca"), MOZILLA_PKIX_ERROR_CA_CERT_USED_AS_END_ENTITY);142 checkEndEntity(certFromFile("ee-v2-BC-cA_ca"), MOZILLA_PKIX_ERROR_CA_CERT_USED_AS_END_ENTITY);143 checkEndEntity(certFromFile("ee-v3-BC-cA_ca"), MOZILLA_PKIX_ERROR_CA_CERT_USED_AS_END_ENTITY);144 checkEndEntity(certFromFile("ee-v4-BC-cA_ca"), MOZILLA_PKIX_ERROR_CA_CERT_USED_AS_END_ENTITY);145 // Section for self-signed certificates:146 checkEndEntity(certFromFile("ss-v1-noBC"), SEC_ERROR_UNKNOWN_ISSUER);147 checkEndEntity(certFromFile("ss-v2-noBC"), SEC_ERROR_UNKNOWN_ISSUER);148 checkEndEntity(certFromFile("ss-v3-noBC"), SEC_ERROR_UNKNOWN_ISSUER);149 checkEndEntity(certFromFile("ss-v4-noBC"), SEC_ERROR_UNKNOWN_ISSUER);150 checkEndEntity(certFromFile("ss-v1-BC-not-cA"), SEC_ERROR_UNKNOWN_ISSUER);151 checkEndEntity(certFromFile("ss-v2-BC-not-cA"), SEC_ERROR_UNKNOWN_ISSUER);152 checkEndEntity(certFromFile("ss-v3-BC-not-cA"), SEC_ERROR_UNKNOWN_ISSUER);153 checkEndEntity(certFromFile("ss-v4-BC-not-cA"), SEC_ERROR_UNKNOWN_ISSUER);154 checkEndEntity(certFromFile("ss-v1-BC-cA"), SEC_ERROR_UNKNOWN_ISSUER);155 checkEndEntity(certFromFile("ss-v2-BC-cA"), SEC_ERROR_UNKNOWN_ISSUER);156 checkEndEntity(certFromFile("ss-v3-BC-cA"), SEC_ERROR_UNKNOWN_ISSUER);157 checkEndEntity(certFromFile("ss-v4-BC-cA"), SEC_ERROR_UNKNOWN_ISSUER);158 checkCertVersion(certFromFile("ss-v1-noBC"), "Version 1");159 checkCertVersion(certFromFile("int-v2-BC-cA_ca"), "Version 2");160 checkCertVersion(certFromFile("ee-v3-BC-not-cA_ca"), "Version 3");161 checkCertVersion(certFromFile("int-v4-BC-not-cA_ca"), "Version 4");...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const { assert, property, fc } = require('fast-check');2const { bc } = require('fast-check-monorepo');3assert(4 property(5 fc.integer(),6 fc.integer(),7 (a, b) => {8 return bc(a, b) === a + b;9 }10);11√ OK: 1000000 shrinks performed (1m 0s 1ms)12√ OK: 1000000 shrinks performed (1m 0s 1ms)13const { assert, property, fc } = require('fast-check');14const { bc } = require('fast-check-monorepo');15assert(16 property(17 fc.integer(),18 fc.integer(),19 (a, b) => {20 return bc(a, b) === a - b;21 }22);23 at Object.fail (node_modules/fast-check/lib/check/runner/Runner.js:79:11)24 at Object.<anonymous> (node_modules/fast-check/lib/check/runner/Runner.js:106:18)25 at Generator.next (<anonymous>)26 at fulfilled (node_modules/fast-check/lib/check/runner/Runner.js:4:58)27 at processTicksAndRejections (internal/process/task_queues.js:97:5)28 at async Object.<anonymous> (node_modules/fast-check/lib/check/property/Property.js:185:16)29 at async Generator.next (<anonymous>)30 at async fulfilled (node_modules/fast-check/lib/check/property/Property.js:4:58)

Full Screen

Using AI Code Generation

copy

Full Screen

1const { bc } = require('fast-check');2const { fc } = require('fast-check');3const { fc } = require('fast-check');4const { bc } = require('fast-check-monorepo');5const { fc } = require('fast-check-monorepo');6const { fc } = require('fast-check-monorepo');7const { bc } = require('fast-check-monorepo');8const { fc } = require('fast-check-monorepo');9const { fc } = require('fast-check-monorepo');10const { bc } = require('fast-check-monorepo');11const { fc } = require('fast-check-monorepo');12const { fc } = require('fast-check-monorepo');13const { bc } = require('fast-check-monorepo');14const { fc } = require('fast-check-monorepo');15const { fc } = require('fast-check-monorepo');16const { bc } = require('fast-check-monorepo');17const { fc } = require('fast-check-monorepo');18const { fc } = require('fast-check-monorepo');19const { bc } = require('fast-check-monorepo');20const { fc } = require('fast-check-monorepo');

Full Screen

Using AI Code Generation

copy

Full Screen

1import * as fc from 'fast-check';2import * as bc from 'fast-check-monorepo';3const arb = bc.arbBigInt();4fc.assert(5 fc.property(arb, (x) => {6 return true;7 })8);9import * as fc from 'fast-check';10import * as bc from 'fast-check-monorepo';11const arb = bc.arbBigInt();12fc.assert(13 fc.property(arb, (x) => {14 return true;15 })16);17import * as fc from 'fast-check';18import * as bc from 'fast-check-monorepo';19const arb = bc.arbBigInt();20fc.assert(21 fc.property(arb, (x) => {22 return true;23 })24);25import * as fc from 'fast-check';26import * as bc from 'fast-check-monorepo';27const arb = bc.arbBigInt();28fc.assert(29 fc.property(arb, (x) => {30 return true;31 })32);33import * as fc from 'fast-check';34import * as bc from 'fast-check-monorepo';35const arb = bc.arbBigInt();36fc.assert(37 fc.property(arb, (x) => {38 return true;39 })40);41import * as fc from 'fast-check';42import * as bc from 'fast-check-monorepo';43const arb = bc.arbBigInt();44fc.assert(45 fc.property(arb, (x) => {46 return true;47 })48);49import * as fc from 'fast-check';50import * as bc from 'fast-check-monorepo';51const arb = bc.arbBigInt();52fc.assert(53 fc.property(arb, (x) => {54 return true;55 })56);57import * as fc from 'fast-check';58import * as bc from 'fast-check-monorepo';59const arb = bc.arbBigInt();60fc.assert(61 fc.property(arb, (x) => {62 return true;63 })64);

Full Screen

Using AI Code Generation

copy

Full Screen

1const { check, property } = require('fast-check');2const { bc } = require('fast-check-monorepo');3const myArbitrary = bc(1, 100);4check(property(myArbitrary, (n) => {5 return n >= 1 && n <= 100;6}));

Full Screen

Using AI Code Generation

copy

Full Screen

1const {bc} = require("fast-check-monorepo");2const {fc} = require("fast-check");3const {property} = require("fast-check");4const {integer} = require("fast-check");5const {string} = require("fast-check");6const {array} = require("fast-check");7const {tuple} = require("fast-check");8const {record} = require("fast-check");9const {option} = require("fast-check");10const {oneof} = require("fast-check");11const {anything} = require("fast-check");12const {constantFrom} = require("fast-check");13const {constant} = require("fast-check");14const {dictionary} = require("fast-check");15const {maxDepth} = require("fast-check");16const {maxSize} = require("fast-check");17const {maxSkips} = require("fast-check");18const {maxRuns} = require("fast-check");19const {asyncProperty} = require("fast-check");20const {asyncPropertyNoShrink} = require("fast-check");21const {asyncPropertyNoShrinkNoShow} = require("fast-check");22const {asyncPropertyNoShrinkNoShowNoRunId} = require("fast-check");23const {asyncPropertyNoShrinkNoShowNoRunIdNoSeed} = require("fast-check");24const {asyncPropertyNoShrinkNoShowNoRunIdNoSeedNoLogger} = require("fast-check");25const {asyncPropertyNoShrinkNoShowNoRunIdNoSeedNoLoggerNoInterruptIf} = require("fast-check");26const {asyncPropertyNoShrinkNoShowNoRunIdNoSeedNoLoggerNoInterruptIfNoRandomType} = require("fast-check");27const {asyncPropertyNoShrinkNoShowNoRunIdNoSeedNoLoggerNoInterruptIfNoRandomTypeNoPath} = require("fast-check");28const {asyncPropertyNoShrinkNoShowNoRunIdNoSeedNoLoggerNoInterruptIfNoRandomTypeNoPathNoNext} = require("fast-check");29const {asyncPropertyNoShrinkNoShowNoRunIdNoSeedNoLoggerNoInterruptIfNoRandomTypeNoPathNoNextNoTimeout} = require("fast-check");30const {asyncPropertyNoShrinkNoShowNoRunIdNoSeedNoLoggerNoInterruptIfNoRandomTypeNoPathNoNextNoTimeoutNoExamples} = require("fast-check");31const {asyncPropertyNoShrinkNoShowNoRunIdNo

Full Screen

Using AI Code Generation

copy

Full Screen

1import * as fc from 'fast-check'2import * as bclib from 'bigint-crypto-utils'3import {bc} from 'fast-check-monorepo'4const bcArb = fc.integer(1, 10).chain(n => bc(n))5const bcArb2 = fc.integer(1, 10).chain(n => bc(n))6fc.assert(7 fc.property(bcArb, bcArb2, (a, b) => {8 return bclib.modPow(a, b, 2n) === bc.modPow(a, b, 2n)9 })

Full Screen

Using AI Code Generation

copy

Full Screen

1const fc = require('fast-check');2const {bc} = require('fast-check-monorepo');3const arb = fc.integer(0, 10);4const arb2 = bc(arb);5const arb3 = bc(arb, {numRuns: 1000});6const arb4 = bc(arb, {numRuns: 1000, seed: 42});7const arb5 = bc(arb, {seed: 42});8const arb6 = bc(arb, {seed: 42, verbose: true});9const arb7 = bc(arb, {seed: 42, verbose: true, path: '/tmp'});10const arb8 = bc(arb, {seed: 42, verbose: true, path: '/tmp', numRuns: 1000});11const arb9 = bc(arb, {seed: 42, verbose: true, path: '/tmp', numRuns: 1000, numShrinks: 1000});12const arb10 = bc(arb, {seed: 42, verbose: true, path: '/tmp', numRuns: 1000, numShrinks: 1000, endOnFailure: true});13const arb11 = bc(arb, {seed: 42, verbose: true, path: '/tmp', numRuns: 1000, numShrinks: 1000, endOnFailure: true, endOnSuccess: true});14const arb12 = bc(arb, {seed: 42, verbose: true, path: '/tmp', numRuns: 1000, numShrinks: 1000, endOnFailure: true, endOnSuccess: true, report: 'minimal'});15const arb13 = bc(arb, {seed: 42, verbose: true, path: '/tmp', numRuns: 1000, numShrinks: 1000, endOnFailure: true, endOnSuccess: true, report: 'minimal', timeout: 1000});16const arb14 = bc(arb, {seed: 42, verbose:

Full Screen

Automation Testing Tutorials

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.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run fast-check-monorepo automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful