How to use hint method in fast-check-monorepo

Best JavaScript code snippet using fast-check-monorepo

ParameterHintManager.js

Source:ParameterHintManager.js Github

copy

Full Screen

1/*2 * Copyright (c) 2013 Adobe Systems Incorporated. All rights reserved.3 *4 * Permission is hereby granted, free of charge, to any person obtaining a5 * copy of this software and associated documentation files (the "Software"),6 * to deal in the Software without restriction, including without limitation7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,8 * and/or sell copies of the Software, and to permit persons to whom the9 * Software is furnished to do so, subject to the following conditions:10 *11 * The above copyright notice and this permission notice shall be included in12 * all copies or substantial portions of the Software.13 *14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING19 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER20 * DEALINGS IN THE SOFTWARE.21 *22 */23/*jslint vars: true, plusplus: true, devel: true, nomen: true, indent: 4, maxerr: 50, regexp: true */24/*global define, brackets, $ */25define(function (require, exports, module) {26 "use strict";27 28 var _ = brackets.getModule("thirdparty/lodash");29 30 var Commands = brackets.getModule("command/Commands"),31 CommandManager = brackets.getModule("command/CommandManager"),32 KeyEvent = brackets.getModule("utils/KeyEvent"),33 Menus = brackets.getModule("command/Menus"),34 Strings = brackets.getModule("strings"),35 HintsUtils2 = require("HintUtils2"),36 ScopeManager = require("ScopeManager");37 /** @const {string} Show Function Hint command ID */38 var SHOW_PARAMETER_HINT_CMD_ID = "showParameterHint", // string must MATCH string in native code (brackets_extensions)39 PUSH_EXISTING_HINT = true,40 OVERWRITE_EXISTING_HINT = false,41 hintContainerHTML = require("text!ParameterHintTemplate.html"),42 KeyboardPrefs = JSON.parse(require("text!keyboard.json"));43 var $hintContainer, // function hint container44 $hintContent, // function hint content holder45 /** @type {{inFunctionCall: boolean, functionCallPos: {line: number, ch: number},46 * fnType: Array.<Object}}47 */48 hintState = {},49 hintStack = [], // stack for previous function hint to restore50 preserveHintStack, // close a function hint without clearing stack51 session; // current editor session, updated by main52 // Constants53 var POINTER_TOP_OFFSET = 4, // Size of margin + border of hint.54 POSITION_BELOW_OFFSET = 4; // Amount to adjust to top position when the preview bubble is below the text55 // keep jslint from complaining about handleCursorActivity being used before56 // it was defined.57 var handleCursorActivity;58 /**59 * Update the current session for use by the Function Hint Manager.60 *61 * @param {Session} value - current session.62 */63 function setSession(value) {64 session = value;65 }66 /**67 * Test if a function hint is being displayed.68 *69 * @return {boolean} - true if a function hint is being displayed, false70 * otherwise.71 */72 function isHintDisplayed() {73 return hintState.visible === true;74 }75 /**76 * Position a function hint.77 *78 * @param {number} xpos79 * @param {number} ypos80 * @param {number} ybot81 */82 function positionHint(xpos, ypos, ybot) {83 var hintWidth = $hintContainer.width(),84 hintHeight = $hintContainer.height(),85 top = ypos - hintHeight - POINTER_TOP_OFFSET,86 left = xpos,87 $editorHolder = $("#editor-holder"),88 editorLeft;89 if ($editorHolder.offset() === undefined) {90 // this happens in jasmine tests that run91 // without a windowed document.92 return;93 }94 editorLeft = $editorHolder.offset().left;95 left = Math.max(left, editorLeft);96 left = Math.min(left, editorLeft + $editorHolder.width() - hintWidth);97 if (top < 0) {98 $hintContainer.removeClass("preview-bubble-above");99 $hintContainer.addClass("preview-bubble-below");100 top = ybot + POSITION_BELOW_OFFSET;101 $hintContainer.offset({102 left: left,103 top: top104 });105 } else {106 $hintContainer.removeClass("preview-bubble-below");107 $hintContainer.addClass("preview-bubble-above");108 $hintContainer.offset({109 left: left,110 top: top - POINTER_TOP_OFFSET111 });112 }113 }114 /**115 * Bold the parameter at the caret.116 *117 * @param {{inFunctionCall: boolean, functionCallPos: {line: number, ch: number}}} functionInfo -118 * tells if the caret is in a function call and the position119 * of the function call.120 */121 function formatHint(functionInfo) {122 var hints = session.getParameterHint(functionInfo.functionCallPos);123 $hintContent.empty();124 $hintContent.addClass("brackets-js-hints");125 function appendSeparators(separators) {126 $hintContent.append(separators);127 }128 function appendParameter(param, index) {129 if (hints.currentIndex === index) {130 $hintContent.append($("<span>")131 .append(_.escape(param))132 .addClass("current-parameter"));133 } else {134 $hintContent.append(_.escape(param));135 }136 }137 if (hints.parameters.length > 0) {138 HintsUtils2.formatParameterHint(hints.parameters, appendSeparators, appendParameter);139 } else {140 $hintContent.append(_.escape(Strings.NO_ARGUMENTS));141 }142 }143 /**144 * Save the state of the current hint. Called when popping up a parameter hint145 * for a parameter, when the parameter already part of an existing parameter146 * hint.147 */148 function pushHintOnStack() {149 hintStack.push(hintState);150 }151 /**152 * Restore the state of the previous function hint.153 *154 * @return {boolean} - true the a parameter hint has been popped, false otherwise.155 */156 function popHintFromStack() {157 if (hintStack.length > 0) {158 hintState = hintStack.pop();159 hintState.visible = false;160 return true;161 }162 return false;163 }164 /**165 * Reset the function hint stack.166 */167 function clearFunctionHintStack() {168 hintStack = [];169 }170 /**171 * Test if the function call at the cursor is different from the currently displayed172 * function hint.173 *174 * @param {{line:number, ch:number}} functionCallPos - the offset of the function call.175 * @return {boolean}176 */177 function hasFunctionCallPosChanged(functionCallPos) {178 var oldFunctionCallPos = hintState.functionCallPos;179 return (oldFunctionCallPos === undefined ||180 oldFunctionCallPos.line !== functionCallPos.line ||181 oldFunctionCallPos.ch !== functionCallPos.ch);182 }183 /**184 * Dismiss the function hint.185 *186 */187 function dismissHint() {188 if (hintState.visible) {189 $hintContainer.hide();190 $hintContent.empty();191 hintState = {};192 session.editor.off("cursorActivity", handleCursorActivity);193 if (!preserveHintStack) {194 clearFunctionHintStack();195 }196 }197 }198 /**199 * Pop up a function hint on the line above the caret position.200 *201 * @param {boolean=} pushExistingHint - if true, push the existing hint on the stack. Default is false, not202 * to push the hint.203 * @param {string=} hint - function hint string from tern.204 * @param {{inFunctionCall: boolean, functionCallPos:205 * {line: number, ch: number}}=} functionInfo -206 * if the functionInfo is already known, it can be passed in to avoid207 * figuring it out again.208 * @return {jQuery.Promise} - The promise will not complete until the209 * hint has completed. Returns null, if the function hint is already210 * displayed or there is no function hint at the cursor.211 *212 */213 function popUpHint(pushExistingHint, hint, functionInfo) {214 functionInfo = functionInfo || session.getFunctionInfo();215 if (!functionInfo.inFunctionCall) {216 dismissHint();217 return null;218 }219 if (hasFunctionCallPosChanged(functionInfo.functionCallPos)) {220 var pushHint = pushExistingHint && isHintDisplayed();221 if (pushHint) {222 pushHintOnStack();223 preserveHintStack = true;224 }225 dismissHint();226 preserveHintStack = false;227 } else if (isHintDisplayed()) {228 return null;229 }230 hintState.functionCallPos = functionInfo.functionCallPos;231 var request = null;232 var $deferredPopUp = $.Deferred();233 if (!hint) {234 request = ScopeManager.requestParameterHint(session, functionInfo.functionCallPos);235 } else {236 session.setFnType(hint);237 request = $.Deferred();238 request.resolveWith(null, [hint]);239 $deferredPopUp.resolveWith(null);240 }241 request.done(function (fnType) {242 var cm = session.editor._codeMirror,243 pos = cm.charCoords(functionInfo.functionCallPos);244 formatHint(functionInfo);245 $hintContainer.show();246 positionHint(pos.left, pos.top, pos.bottom);247 hintState.visible = true;248 hintState.fnType = fnType;249 session.editor.on("cursorActivity", handleCursorActivity);250 $deferredPopUp.resolveWith(null);251 }).fail(function () {252 hintState = {};253 });254 return $deferredPopUp;255 }256 /**257 * Pop up a function hint on the line above the caret position if the character before258 * the current cursor is an open parenthesis259 *260 * @return {jQuery.Promise} - The promise will not complete until the261 * hint has completed. Returns null, if the function hint is already262 * displayed or there is no function hint at the cursor.263 */264 function popUpHintAtOpenParen() {265 var functionInfo = session.getFunctionInfo();266 if (functionInfo.inFunctionCall) {267 var token = session.getToken();268 269 if (token && token.string === "(") {270 return popUpHint();271 }272 } else {273 dismissHint();274 }275 276 return null;277 }278 279 /**280 * Show the parameter the cursor is on in bold when the cursor moves.281 * Dismiss the pop up when the cursor moves off the function.282 */283 handleCursorActivity = function () {284 var functionInfo = session.getFunctionInfo();285 if (functionInfo.inFunctionCall) {286 // If in a different function hint, then dismiss the old one and287 // display the new one if there is one on the stack288 if (hasFunctionCallPosChanged(functionInfo.functionCallPos)) {289 if (popHintFromStack()) {290 var poppedFunctionCallPos = hintState.functionCallPos,291 currentFunctionCallPos = functionInfo.functionCallPos;292 if (poppedFunctionCallPos.line === currentFunctionCallPos.line &&293 poppedFunctionCallPos.ch === currentFunctionCallPos.ch) {294 preserveHintStack = true;295 popUpHint(OVERWRITE_EXISTING_HINT,296 hintState.fnType, functionInfo);297 preserveHintStack = false;298 return;299 }300 } else {301 dismissHint();302 }303 }304 formatHint(functionInfo);305 return;306 }307 dismissHint();308 };309 /**310 * Enable cursor tracking in the current session.311 *312 * @param {Session} session - session to start cursor tracking on.313 */314 function startCursorTracking(session) {315 session.editor.on("cursorActivity", handleCursorActivity);316 }317 /**318 * Stop cursor tracking in the current session.319 *320 * Use this to move the cursor without changing the function hint state.321 *322 * @param {Session} session - session to stop cursor tracking on.323 */324 function stopCursorTracking(session) {325 session.editor.off("cursorActivity", handleCursorActivity);326 }327 /**328 * Show a parameter hint in its own pop-up.329 *330 */331 function handleShowParameterHint() {332 // Pop up function hint333 popUpHint();334 }335 /**336 * Install function hint listeners.337 *338 * @param {Editor} editor - editor context on which to listen for339 * changes340 */341 function installListeners(editor) {342 editor.on("keydown", function (event, editor, domEvent) {343 if (domEvent.keyCode === KeyEvent.DOM_VK_ESCAPE) {344 dismissHint();345 }346 }).on("scroll", function () {347 dismissHint();348 });349 }350 /**351 * Add the function hint command at start up.352 */353 function addCommands() {354 /* Register the command handler */355 CommandManager.register(Strings.CMD_SHOW_PARAMETER_HINT, SHOW_PARAMETER_HINT_CMD_ID, handleShowParameterHint);356 // Add the menu items357 var menu = Menus.getMenu(Menus.AppMenuBar.EDIT_MENU);358 if (menu) {359 menu.addMenuItem(SHOW_PARAMETER_HINT_CMD_ID, KeyboardPrefs.showParameterHint, Menus.AFTER, Commands.SHOW_CODE_HINTS);360 }361 // Close the function hint when commands are executed, except for the commands362 // to show function hints for code hints.363 CommandManager.on("beforeExecuteCommand", function (event, commandId) {364 if (commandId !== SHOW_PARAMETER_HINT_CMD_ID &&365 commandId !== Commands.SHOW_CODE_HINTS) {366 dismissHint();367 }368 });369 }370 // Create the function hint container371 $hintContainer = $(hintContainerHTML).appendTo($("body"));372 $hintContent = $hintContainer.find(".function-hint-content");373 exports.PUSH_EXISTING_HINT = PUSH_EXISTING_HINT;374 exports.addCommands = addCommands;375 exports.dismissHint = dismissHint;376 exports.installListeners = installListeners;377 exports.isHintDisplayed = isHintDisplayed;378 exports.popUpHint = popUpHint;379 exports.popUpHintAtOpenParen = popUpHintAtOpenParen;380 exports.setSession = setSession;381 exports.startCursorTracking = startCursorTracking;382 exports.stopCursorTracking = stopCursorTracking;...

Full Screen

Full Screen

validator.js

Source:validator.js Github

copy

Full Screen

1(function ( $ ) {2 "use strict";3 $.widget( "metro.validator" , {4 version: "1.0.0",5 options: {6 showErrorState: true,7 showErrorHint: true,8 showRequiredState: true,9 showSuccessState: true,10 hintSize: 0,11 hintBackground: '#FFFCC0',12 hintColor: '#000000',13 hideError: 2000,14 hideHint: 5000,15 hintEasing: 'easeInQuad',16 hintEasingTime: 400,17 hintMode: 'hint', // hint, line18 hintPosition: 'right',19 focusInput: true,20 onBeforeSubmit: function(form, result){return true;},21 onErrorInput: function(input){},22 onSubmit: function(form){return true;}23 },24 _scroll: 0,25 funcs: {26 required: function(val){27 return val.trim() !== "";28 },29 minlength: function(val, len){30 if (len == undefined || isNaN(len) || len <= 0) {31 return false;32 }33 return val.trim().length >= len;34 },35 maxlength: function(val, len){36 if (len == undefined || isNaN(len) || len <= 0) {37 return false;38 }39 return val.trim().length <= len;40 },41 min: function(val, min_value){42 if (min_value == undefined || isNaN(min_value)) {43 return false;44 }45 if (val.trim() === "") {46 return false;47 }48 if (isNaN(val)) {49 return false;50 }51 return val >= min_value;52 },53 max: function(val, max_value){54 if (max_value == undefined || isNaN(max_value)) {55 return false;56 }57 if (val.trim() === "") {58 return false;59 }60 if (isNaN(val)) {61 return false;62 }63 return val <= max_value;64 },65 email: function(val){66 return /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i.test(val);67 },68 url: function(val){69 return /^(?:[a-z]+:)?\/\//i.test(val);70 },71 date: function(val){72 return !!(new Date(val) !== "Invalid Date" && !isNaN(new Date(val)));73 },74 number: function(val){75 return (val - 0) == val && (''+val).trim().length > 0;76 },77 digits: function(val){78 return /^\d+$/.test(val);79 },80 hexcolor: function(val){81 return /(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i.test(val);82 },83 pattern: function(val, pat){84 if (pat == undefined) {85 return false;86 }87 var reg = new RegExp(pat);88 return reg.test(val);89 }90 },91 _create: function () {92 var that = this, element = this.element, o = this.options;93 $.each(element.data(), function(key, value){94 if (key in o) {95 try {96 o[key] = $.parseJSON(value);97 } catch (e) {98 o[key] = value;99 }100 }101 });102 if (o.hintMode !== 'line') {103 o.hintMode = 'hint2';104 }105 this._scroll = $(window).scrollTop();106 this._createValidator();107 element.data('validator', this);108 },109 _createValidator: function(){110 var that = this, element = this.element, o = this.options;111 var inputs = element.find("[data-validate-func]");112 element.attr('novalidate', 'novalidate');113 if (o.showRequiredState) {114 $.each(inputs, function(){115 var input = $(this);116 if (input.parent().hasClass('input-control')) {117 input.parent().addClass('required');118 } else {119 input.addClass('required');120 }121 });122 }123 inputs.on('focus', function(){124 });125 //console.log(this._scroll);126 $(window).scroll(function(e){127 var st = $(this).scrollTop();128 var delta = isNaN(st - this._scroll) ? 0 : st - this._scroll;129 $(".validator-hint.hint2").css({130 top: '-='+delta131 });132 this._scroll = st;133 });134 if (element[0].onsubmit) {135 this._onsubmit = element[0].onsubmit;136 element[0].onsubmit = null;137 } else {138 this._onsubmit = null;139 }140 element[0].onsubmit = function(){141 return that._submit();142 };143 },144 _submit: function(){145 var that = this, element = this.element, o = this.options;146 var inputs = element.find("[data-validate-func]");147 var submit = element.find(":submit").attr('disabled', 'disabled').addClass('disabled');148 var result = 0;149 $('.validator-hint').hide();150 inputs.removeClass('error success');151 $.each(inputs, function(i, v){152 var input = $(v);153 if (input.parent().hasClass('input-control')) {154 input.parent().removeClass('error success');155 }156 });157 $.each(inputs, function(i, v){158 var input = $(v);159 var func = input.data('validateFunc'), arg = input.data('validateArg');160 var this_result = that.funcs[func](input.val(), arg);161 if (!this_result) {162 if (typeof o.onErrorInput === 'string') {163 window[o.onErrorInput](input);164 } else {165 o.onErrorInput(input);166 }167 }168 if (!this_result && o.showErrorState) {169 that._showError(input);170 }171 if (!this_result && o.showErrorHint) {172 setTimeout(function(){173 that._showErrorHint(input);174 }, i*100);175 }176 if (this_result && o.showSuccessState) {177 that._showSuccess(input);178 }179 if (!this_result && i == 0 && o.focusInput) {180 input.focus();181 }182 result += !this_result ? 1 : 0;183 });184 if (typeof o.onBeforeSubmit === 'string') {185 result += !window[o.onBeforeSubmit](element, result) ? 1 : 0;186 } else {187 result += !o.onBeforeSubmit(element, result) ? 1 : 0;188 }189 if (result !== 0) {190 submit.removeAttr('disabled').removeClass('disabled');191 return false;192 }193 result = (typeof o.onSubmit === 'string') ? window[o.onSubmit](element[0]) : result = o.onSubmit(element[0]);194 submit.removeAttr('disabled').removeClass('disabled');195 return result;196 },197 _showSuccess: function(input){198 if (input.parent().hasClass('input-control')) {199 input.parent().addClass('success');200 } else {201 input.addClass('success');202 }203 },204 _showError: function(input){205 var o = this.options;206 if (input.parent().hasClass('input-control')) {207 input.parent().addClass('error');208 } else {209 input.addClass('error');210 }211 if (o.hideError && o.hideError > 0) {212 setTimeout(function(){213 input.parent().removeClass('error');214 }, o.hideError);215 }216 },217 _showErrorHint: function(input){218 var o = this.options,219 msg = input.data('validateHint'),220 pos = input.data('validateHintPosition') || o.hintPosition,221 mode = input.data('validateHintMode') || o.hintMode,222 background = input.data('validateHintBackground') || o.hintBackground,223 color = input.data('validateHintColor') || o.hintColor;224 var hint, top, left;225 if (msg === undefined) {226 return false;227 }228 hint = $("<div/>").addClass(mode+' validator-hint');//.appendTo(input.parent());229 hint.html(msg !== undefined ? this._format(msg, input.val()) : '');230 hint.css({231 'min-width': o.hintSize232 });233 if (background.isColor()) {234 hint.css('background-color', background);235 } else {236 hint.addClass(background);237 }238 if (color.isColor()) {239 hint.css('color', color);240 } else {241 hint.addClass(color);242 }243 // Position244 if (mode === 'line') {245 hint.addClass('hint2').addClass('line');246 hint.css({247 'position': 'relative',248 'width': input.parent().hasClass('input-control') ? input.parent().width() : input.width(),249 'z-index': 100250 });251 hint.appendTo(input.parent());252 hint.fadeIn(o.hintEasingTime, function(){253 setTimeout(function () {254 hint.hide().remove();255 }, o.hideHint);256 });257 } else {258 hint.appendTo("body");259 // right260 if (pos === 'right') {261 left = input.offset().left + input.outerWidth() + 15 - $(window).scrollLeft();262 top = input.offset().top + input.outerHeight() / 2 - hint.outerHeight() / 2 - $(window).scrollTop() - 10;263 hint.addClass(pos);264 hint.css({265 top: top,266 left: $(window).width() + 100267 });268 hint.show().animate({269 left: left270 }, o.hintEasingTime, o.hintEasing, function () {271 setTimeout(function () {272 hint.hide().remove();273 }, o.hideHint);274 });275 } else if (pos === 'left') {276 left = input.offset().left - hint.outerWidth() - 10 - $(window).scrollLeft();277 top = input.offset().top + input.outerHeight() / 2 - hint.outerHeight() / 2 - $(window).scrollTop() - 10;278 hint.addClass(pos);279 hint.css({280 top: top,281 left: -input.offset().left - hint.outerWidth() - 10282 });283 hint.show().animate({284 left: left285 }, o.hintEasingTime, o.hintEasing, function () {286 setTimeout(function () {287 hint.hide().remove();288 }, o.hideHint);289 });290 } else if (pos === 'top') {291 left = input.offset().left + input.outerWidth()/2 - hint.outerWidth()/2 - $(window).scrollLeft();292 top = input.offset().top - $(window).scrollTop() - hint.outerHeight() - 20;293 hint.addClass(pos);294 hint.css({295 top: -hint.outerHeight(),296 left: left297 }).show().animate({298 top: top299 }, o.hintEasingTime, o.hintEasing, function(){300 setTimeout(function () {301 hint.hide().remove();302 }, o.hideHint);303 });304 } else /*bottom*/ {305 left = input.offset().left + input.outerWidth()/2 - hint.outerWidth()/2 - $(window).scrollLeft();306 top = input.offset().top - $(window).scrollTop() + input.outerHeight();307 hint.addClass(pos);308 hint.css({309 top: $(window).height(),310 left: left311 }).show().animate({312 top: top313 }, o.hintEasingTime, o.hintEasing, function(){314 setTimeout(function () {315 hint.hide().remove();316 }, o.hideHint);317 });318 }319 }320 },321 _format: function( source, params ) {322 if ( arguments.length === 1 ) {323 return function() {324 var args = $.makeArray( arguments );325 args.unshift( source );326 return $.validator.format.apply( this, args );327 };328 }329 if ( arguments.length > 2 && params.constructor !== Array ) {330 params = $.makeArray( arguments ).slice( 1 );331 }332 if ( params.constructor !== Array ) {333 params = [ params ];334 }335 $.each( params, function( i, n ) {336 source = source.replace( new RegExp( "\\{" + i + "\\}", "g" ), function() {337 return n;338 });339 });340 return source;341 },342 _destroy: function () {343 },344 _setOption: function ( key, value ) {345 this._super('_setOption', key, value);346 }347 });...

Full Screen

Full Screen

hint.js

Source:hint.js Github

copy

Full Screen

1(function( $ ) {2 "use strict";3 $.widget("metro.hint", {4 version: "3.0.0",5 options: {6 hintPosition: "auto", // bottom, top, left, right, auto7 hintBackground: '#FFFCC0',8 hintColor: '#000000',9 hintMaxSize: 200,10 hintMode: 'default',11 hintShadow: false,12 hintBorder: true,13 _hint: undefined14 },15 _create: function(){16 var that = this, element = this.element;17 var o = this.options;18 this.element.on('mouseenter', function(e){19 $(".hint, .hint2").remove();20 that.createHint();21 o._hint.show();22 e.preventDefault();23 });24 this.element.on('mouseleave', function(e){25 o._hint.hide().remove();26 e.preventDefault();27 });28 //element.data('hint', this);29 },30 createHint: function(){31 var that = this, element = this.element,32 hint = element.data('hint').split("|"),33 o = this.options;34 var _hint;35 $.each(element.data(), function(key, value){36 if (key in o) {37 try {38 o[key] = $.parseJSON(value);39 } catch (e) {40 o[key] = value;41 }42 }43 });44 if (element[0].tagName === 'TD' || element[0].tagName === 'TH') {45 var wrp = $("<div/>").css("display", "inline-block").html(element.html());46 element.html(wrp);47 element = wrp;48 }49 var hint_title = hint.length > 1 ? hint[0] : false;50 var hint_text = hint.length > 1 ? hint[1] : hint[0];51 _hint = $("<div/>").appendTo('body');52 if (o.hintMode === 2) {53 _hint.addClass('hint2');54 } else {55 _hint.addClass('hint');56 }57 if (!o.hintBorder) {58 _hint.addClass('no-border');59 }60 if (hint_title) {61 $("<div/>").addClass("hint-title").html(hint_title).appendTo(_hint);62 }63 $("<div/>").addClass("hint-text").html(hint_text).appendTo(_hint);64 _hint.addClass(o.position);65 if (o.hintShadow) {_hint.addClass("shadow");}66 if (o.hintBackground) {67 if (o.hintBackground.isColor()) {68 _hint.css("background-color", o.hintBackground);69 } else {70 _hint.addClass(o.hintBackground);71 }72 }73 if (o.hintColor) {74 if (o.hintColor.isColor()) {75 _hint.css("color", o.hintColor);76 } else {77 _hint.addClass(o.hintColor);78 }79 }80 if (o.hintMaxSize > 0) {81 _hint.css({82 'max-width': o.hintMaxSize83 });84 }85 //if (o.hintMode !== 'default') {86 // _hint.addClass(o.hintMode);87 //}88 if (o.hintPosition === 'top') {89 _hint.addClass('top');90 _hint.css({91 top: element.offset().top - $(window).scrollTop() - _hint.outerHeight() - 20,92 left: o.hintMode === 2 ? element.offset().left + element.outerWidth()/2 - _hint.outerWidth()/2 - $(window).scrollLeft(): element.offset().left - $(window).scrollLeft()93 });94 } else if (o.hintPosition === 'right') {95 _hint.addClass('right');96 _hint.css({97 top: o.hintMode === 2 ? element.offset().top + element.outerHeight()/2 - _hint.outerHeight()/2 - $(window).scrollTop() - 10 : element.offset().top - 10 - $(window).scrollTop(),98 left: element.offset().left + element.outerWidth() + 15 - $(window).scrollLeft()99 });100 } else if (o.hintPosition === 'left') {101 _hint.addClass('left');102 _hint.css({103 top: o.hintMode === 2 ? element.offset().top + element.outerHeight()/2 - _hint.outerHeight()/2 - $(window).scrollTop() - 10 : element.offset().top - 10 - $(window).scrollTop(),104 left: element.offset().left - _hint.outerWidth() - 10 - $(window).scrollLeft()105 });106 } else {107 _hint.addClass('bottom');108 _hint.css({109 top: element.offset().top - $(window).scrollTop() + element.outerHeight(),110 left: o.hintMode === 2 ? element.offset().left + element.outerWidth()/2 - _hint.outerWidth()/2 - $(window).scrollLeft(): element.offset().left - $(window).scrollLeft()111 });112 }113 o._hint = _hint;114 },115 _destroy: function(){116 },117 _setOption: function(key, value){118 this._super('_setOption', key, value);119 }120 });...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1const fc = require('fast-check');2const { hint } = require('fast-check');3fc.assert(4 fc.property(fc.string(), fc.string(), fc.string(), (s1, s2, s3) => {5 hint('hint message');6 return s1 + s2 === s3;7 }),8);

Full Screen

Using AI Code Generation

copy

Full Screen

1const fc = require('fast-check');2fc.assert(3 fc.property(fc.integer(), fc.integer(), (a, b) => {4 return a + b >= a;5 }),6 { verbose: true }7);8const fc = require('fast-check');9fc.assert(10 fc.property(fc.integer(), fc.integer(), (a, b) => {11 return a + b >= a;12 }),13 { verbose: true }14);15 at Object.<anonymous> (node_modules/fast-check/lib/check/arbitrary/AsyncFunctionArbitrary.js:4:37)16 at Module._compile (internal/modules/cjs/loader.js:776:30)17 at Object.Module._extensions..js (internal/modules/cjs/loader.js:787:10)18 at Module.load (internal/modules/cjs/loader.js:653:32)19 at tryModuleLoad (internal/modules/cjs/loader.js:593:12)20 at Function.Module._load (internal/modules/cjs/loader.js:585:3)21 at Module.require (internal/modules/cjs/loader.js:690:17)22 at require (internal/modules/cjs/helpers.js:25:18)23 at Object.<anonymous> (node_modules/fast-check/lib/check/arbitrary/AsyncFunctionArbitrary.js:1:1)24 at Module._compile (internal/modules/cjs/loader.js:776:30)

Full Screen

Using AI Code Generation

copy

Full Screen

1const fc = require("fast-check");2const { hint } = require("fast-check");3fc.assert(4 fc.property(fc.array(fc.integer()), (arr) => {5 return arr.length > 0;6 }),7 { seed: 1568831088, path: "test3.js", endOnFailure: true }8);9const fc = require("fast-check");10const { hint } = require("fast-check");11fc.assert(12 fc.property(fc.array(fc.integer()), (arr) => {13 return arr.length > 0;14 }),15 { seed: 1568831088, path: "test4.js", endOnFailure: true }16);17const fc = require("fast-check");18const { hint } = require("fast-check");19fc.assert(20 fc.property(fc.array(fc.integer()), (arr) => {21 return arr.length > 0;22 }),23 { seed: 1568831088, path: "test5.js", endOnFailure: true }24);25const fc = require("fast-check");26const { hint } = require("fast-check");27fc.assert(28 fc.property(fc.array(fc.integer()), (arr) => {29 return arr.length > 0;30 }),31 { seed: 1568831088, path: "test6.js", endOnFailure: true }32);

Full Screen

Using AI Code Generation

copy

Full Screen

1const fc = require('fast-check');2const { hint } = require('fast-check/lib/check/arbitrary/hint');3const { string } = require('fast-check/lib/arbitrary/string');4const { oneof } = require('fast-check/lib/arbitrary/oneof');5const arb = oneof(string(), string({ minLength: 10, maxLength: 10 }));6const log = (v) => {7 console.log(`hint(${JSON.stringify(v)}) = ${JSON.stringify(hint(arb, v))}`);8};9log('abc');10log('1234567890');11log('12345678901');12log('12345678901234567890');13log('123456789012345678901234567890');14log('1234567890123456789012345678901');15log('12345678901234567890123456789012');16log('1234567890123456789012345678901234567890');17log('12345678901234567890123456789012345678901');18log('12345678901234567890123456789012345678901234567890');19log('123456789012345678901234567890123456789012345678901234567890');20log('1234567890123456789012345678901234567890123456789012345678901');21log('12345678901234567890123456789012345678901234567890123456789012');22log('1234567890123456789012345678901234567890123456789012345678901234567890');23log('12345678901234567890123456789012345678901234567890123456789012345678901');24log('12345678901234567

Full Screen

Using AI Code Generation

copy

Full Screen

1const fc = require('fast-check');2const { hint } = require('fast-check/lib/check/runner/Hint');3const { run } = require('fast-check/lib/check/runner/Runner');4const { check } = require('fast-check/lib/check/runner/Check');5const { configureGlobal } = require('fast-check/lib/check/runner/Configuration');6const { runModel } = require('fast-check/lib/check/model/ModelRunner');7const { modelRun } = require('fast-check/lib/check/model/ModelCheck');8const { configureGlobal: configureModelGlobal } = require('fast-check/lib/check/model/ModelConfiguration');9const { runProperty } = require('fast-check/lib/check/property/Property');10const { property } = require('fast-check/lib/check/property/PropertyCheck');11const { configureGlobal: configurePropertyGlobal } = require('fast-check/lib/check/property/PropertyConfiguration');12const { configureGlobal: configureAsyncPropertyGlobal } = require('fast-check/lib/check/asyncproperty/AsyncPropertyConfiguration');13const { asyncProperty } = require('fast-check/lib/check/asyncproperty/AsyncPropertyCheck');14const { runAsyncProperty } = require('fast-check/lib/check/asyncproperty/AsyncProperty');15const { configureGlobal: configureCommandGlobal } = require('fast-check/lib/check/command/CommandConfiguration');16const { command } = require('fast-check/lib/check/command/CommandCheck');17const { runCommand } = require('fast-check/lib/check/command/Command');18const { configureGlobal: configureAsyncCommandGlobal } = require('fast-check/lib/check/asynccommand/AsyncCommandConfiguration');19const { asyncCommand } = require('fast-check/lib/check/asynccommand/AsyncCommandCheck');20const { runAsyncCommand } = require('fast-check/lib/check/asynccommand/AsyncCommand');21const { configureGlobal: configureHookGlobal } = require('fast-check/lib/check/hook/HookConfiguration');22const { runHook } = require('fast-check/lib/check/hook/Hook');23const { hook } = require('fast-check/lib/check/hook/HookCheck');24const { configureGlobal: configureAsyncHookGlobal } = require('fast-check/lib/check/asynchook/AsyncHookConfiguration');25const { runAsyncHook } = require('fast-check/lib/check/asynchook/AsyncHook');26const { asyncHook } = require('fast-check/lib/check/asynchook/AsyncHookCheck');27const { configureGlobal: configureSh

Full Screen

Using AI Code Generation

copy

Full Screen

1const fc = require("fast-check");2const { hint } = fc;3const isEven = n => n % 2 === 0;4const isOdd = n => n % 2 !== 0;5const isEvenArb = fc.integer().filter(isEven);6const isOddArb = fc.integer().filter(isOdd);7fc.assert(8 fc.property(isEvenArb, isOddArb, (even, odd) => {9 hint(`even = ${even}, odd = ${odd}`);10 return even + odd === 0;11 })12);13FastCheck: Failure after 1 tests and 0 shrinks (seed: 0, shrunkOnce: false)

Full Screen

Using AI Code Generation

copy

Full Screen

1const { hint } = require('fast-check');2const { string } = require('fast-check');3const { property } = require('fast-check');4const isPalindrome = (s) => s === s.split('').reverse().join('');5const fc = require('fast-check');6 .string()7 .filter((s) => isPalindrome(s));8property(isPalindromeArb, (s) => isPalindrome(s)).check({ hint: hint });9const { hint } = require('fast-check');10const { string } = require('fast-check');11const { property } = require('fast-check');12const isPalindrome = (s) => s === s.split('').reverse().join('');13const fc = require('fast-check');14 .string()15 .filter((s) => isPalindrome(s));16property(isPalindromeArb, (s) => isPalindrome(s)).check({ hint: hint });17const { hint } = require('fast-check');18const { string } = require('fast-check');19const { property } = require('fast-check');20const isPalindrome = (s) => s === s.split('').reverse().join('');21const fc = require('fast-check');22 .string()23 .filter((s) => isPalindrome(s));24property(isPalindromeArb, (s) => isPalindrome(s)).check({ hint: hint });25const { hint } = require('fast-check');26const { string } = require('fast-check');27const { property } = require('fast-check');28const isPalindrome = (s) => s === s.split('').reverse().join('');29const fc = require('fast-check');30 .string()31 .filter((s) => isPalindrome(s));32property(isPalindromeArb, (s) => isPalindrome(s)).check({ hint: hint });33const { hint } = require('fast-check');34const { string } = require('fast-check');35const { property } = require

Full Screen

Using AI Code Generation

copy

Full Screen

1const fc = require('fast-check');2const {hint} = require('fast-check/lib/check/arbitrary/definition/Arbitrary.js');3const {string} = require('fast-check/lib/check/arbitrary/StringArbitrary.js');4const {tuple} = require('fast-check/lib/check/arbitrary/TupleArbitrary.js');5const {map} = require('fast-check/lib/check/arbitrary/definition/MapArbitrary.js');6const {option} = require('fast-check/lib/check/arbitrary/OptionArbitrary.js');7const {oneof} = require('fast-check/lib/check/arbitrary/definition/OneOfArbitrary.js');8const {constantFrom} = require('fast-check/lib/check/arbitrary/definition/ConstantFromArbitrary.js');9const {integer} = require('fast-check/lib/check/arbitrary/IntegerArbitrary.js');10const {float} = require('fast-check/lib/check/arbitrary/FloatArbitrary.js');11const {dictionary} = require('fast-check/lib/check/arbitrary/DictionaryArbitrary.js');12const {json} = require('fast-check/lib/check/arbitrary/JsonArbitrary.js');13const {date} = require('fast-check/lib/check/arbitrary/DateArbitrary.js');14const {record} = require('fast-check/lib/check/arbitrary/RecordArbitrary.js');15const {array} = require('fast-check/lib/check/arbitrary/ArrayArbitrary.js');16const {unicodeString} = require('fast-check/lib/check/arbitrary/UnicodeStringArbitrary.js');17const {unicodeJson} = require('fast-check/lib/check/arbitrary/UnicodeJsonArbitrary.js');18const {unicodeJsonObject} = require('fast-check/lib/check/arbitrary/UnicodeJsonObjectArbitrary.js');19const {unicodeJsonString} = require('fast-check/lib/check/arbitrary/UnicodeJsonStringArbitrary.js');20const {unicodeJsonArray} = require('fast-check/lib/check/arbitrary/UnicodeJsonArrayArbitrary.js');21const {unicodeJsonRecord} = require('fast-check/lib/check/arbitrary/UnicodeJsonRecordArbitrary.js');22const {unicodeJsonDictionary} = require('fast-check/lib/check/arbitrary/UnicodeJsonDictionaryArbitrary.js');23const {unicodeJsonConstant} = require('fast-check/lib/check/arbitrary/UnicodeJsonConstantArbitrary.js');24const {unicodeJsonConstantFrom} = require('fast-check/lib/check/arbitrary/UnicodeJsonConstantFromArbitrary.js');

Full Screen

Using AI Code Generation

copy

Full Screen

1const { hint } = require('fast-check');2const { generate } = require('./test2');3const hints = hint(generate, { seed: 1, path: 'test2.js' });4console.log(hints);5const { generate } = require('fast-check');6const generate = () => generate(arbDate(), 10);7module.exports = { generate };8const { generate } = require('fast-check');9const generate = () => generate(arbDate(), 10);10module.exports = { generate };

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