How to use n.util.clone method in sinon

Best JavaScript code snippet using sinon

prism-textile.js

Source:prism-textile.js Github

copy

Full Screen

1(function(Prism) {2 // We don't allow for pipes inside parentheses3 // to not break table pattern |(. foo |). bar |4 var modifierRegex = '(?:\\([^|)]+\\)|\\[[^\\]]+\\]|\\{[^}]+\\})+';5 var modifierTokens = {6 'css': {7 pattern: /\{[^}]+\}/,8 inside: {9 rest: Prism.languages.css10 }11 },12 'class-id': {13 pattern: /(\()[^)]+(?=\))/,14 lookbehind: true,15 alias: 'attr-value'16 },17 'lang': {18 pattern: /(\[)[^\]]+(?=\])/,19 lookbehind: true,20 alias: 'attr-value'21 },22 // Anything else is punctuation (the first pattern is for row/col spans inside tables)23 'punctuation': /[\\\/]\d+|\S/24 };25 Prism.languages.textile = Prism.languages.extend('markup', {26 'phrase': {27 pattern: /(^|\r|\n)\S[\s\S]*?(?=$|\r?\n\r?\n|\r\r)/,28 lookbehind: true,29 inside: {30 // h1. Header 131 'block-tag': {32 pattern: RegExp('^[a-z]\\w*(?:' + modifierRegex + '|[<>=()])*\\.'),33 inside: {34 'modifier': {35 pattern: RegExp('(^[a-z]\\w*)(?:' + modifierRegex + '|[<>=()])+(?=\\.)'),36 lookbehind: true,37 inside: Prism.util.clone(modifierTokens)38 },39 'tag': /^[a-z]\w*/,40 'punctuation': /\.$/41 }42 },43 // # List item44 // * List item45 'list': {46 pattern: RegExp('^[*#]+(?:' + modifierRegex + ')?\\s+.+', 'm'),47 inside: {48 'modifier': {49 pattern: RegExp('(^[*#]+)' + modifierRegex),50 lookbehind: true,51 inside: Prism.util.clone(modifierTokens)52 },53 'punctuation': /^[*#]+/54 }55 },56 // | cell | cell | cell |57 'table': {58 // Modifiers can be applied to the row: {color:red}.|1|2|3|59 // or the cell: |{color:red}.1|2|3|60 pattern: RegExp('^(?:(?:' + modifierRegex + '|[<>=()^~])+\\.\\s*)?(?:\\|(?:(?:' + modifierRegex + '|[<>=()^~_]|[\\\\/]\\d+)+\\.)?[^|]*)+\\|', 'm'),61 inside: {62 'modifier': {63 // Modifiers for rows after the first one are64 // preceded by a pipe and a line feed65 pattern: RegExp('(^|\\|(?:\\r?\\n|\\r)?)(?:' + modifierRegex + '|[<>=()^~_]|[\\\\/]\\d+)+(?=\\.)'),66 lookbehind: true,67 inside: Prism.util.clone(modifierTokens)68 },69 'punctuation': /\||^\./70 }71 },72 'inline': {73 pattern: RegExp('(\\*\\*|__|\\?\\?|[*_%@+\\-^~])(?:' + modifierRegex + ')?.+?\\1'),74 inside: {75 // Note: superscripts and subscripts are not handled specifically76 // *bold*, **bold**77 'bold': {78 pattern: RegExp('((^\\*\\*?)(?:' + modifierRegex + ')?).+?(?=\\2)'),79 lookbehind: true80 },81 // _italic_, __italic__82 'italic': {83 pattern: RegExp('((^__?)(?:' + modifierRegex + ')?).+?(?=\\2)'),84 lookbehind: true85 },86 // ??cite??87 'cite': {88 pattern: RegExp('(^\\?\\?(?:' + modifierRegex + ')?).+?(?=\\?\\?)'),89 lookbehind: true,90 alias: 'string'91 },92 // @code@93 'code': {94 pattern: RegExp('(^@(?:' + modifierRegex + ')?).+?(?=@)'),95 lookbehind: true,96 alias: 'keyword'97 },98 // +inserted+99 'inserted': {100 pattern: RegExp('(^\\+(?:' + modifierRegex + ')?).+?(?=\\+)'),101 lookbehind: true102 },103 // -deleted-104 'deleted': {105 pattern: RegExp('(^-(?:' + modifierRegex + ')?).+?(?=-)'),106 lookbehind: true107 },108 // %span%109 'span': {110 pattern: RegExp('(^%(?:' + modifierRegex + ')?).+?(?=%)'),111 lookbehind: true112 },113 'modifier': {114 pattern: RegExp('(^\\*\\*|__|\\?\\?|[*_%@+\\-^~])' + modifierRegex),115 lookbehind: true,116 inside: Prism.util.clone(modifierTokens)117 },118 'punctuation': /[*_%?@+\-^~]+/119 }120 },121 // [alias]http://example.com122 'link-ref': {123 pattern: /^\[[^\]]+\]\S+$/m,124 inside: {125 'string': {126 pattern: /(\[)[^\]]+(?=\])/,127 lookbehind: true128 },129 'url': {130 pattern: /(\])\S+$/,131 lookbehind: true132 },133 'punctuation': /[\[\]]/134 }135 },136 // "text":http://example.com137 // "text":link-ref138 'link': {139 pattern: RegExp('"(?:' + modifierRegex + ')?[^"]+":.+?(?=[^\\w/]?(?:\\s|$))'),140 inside: {141 'text': {142 pattern: RegExp('(^"(?:' + modifierRegex + ')?)[^"]+(?=")'),143 lookbehind: true144 },145 'modifier': {146 pattern: RegExp('(^")' + modifierRegex),147 lookbehind: true,148 inside: Prism.util.clone(modifierTokens)149 },150 'url': {151 pattern: /(:).+/,152 lookbehind: true153 },154 'punctuation': /[":]/155 }156 },157 // !image.jpg!158 // !image.jpg(Title)!:http://example.com159 'image': {160 pattern: RegExp('!(?:' + modifierRegex + '|[<>=()])*[^!\\s()]+(?:\\([^)]+\\))?!(?::.+?(?=[^\\w/]?(?:\\s|$)))?'),161 inside: {162 'source': {163 pattern: RegExp('(^!(?:' + modifierRegex + '|[<>=()])*)[^!\\s()]+(?:\\([^)]+\\))?(?=!)'),164 lookbehind: true,165 alias: 'url'166 },167 'modifier': {168 pattern: RegExp('(^!)(?:' + modifierRegex + '|[<>=()])+'),169 lookbehind: true,170 inside: Prism.util.clone(modifierTokens)171 },172 'url': {173 pattern: /(:).+/,174 lookbehind: true175 },176 'punctuation': /[!:]/177 }178 },179 // Footnote[1]180 'footnote': {181 pattern: /\b\[\d+\]/,182 alias: 'comment',183 inside: {184 'punctuation': /\[|\]/185 }186 },187 // CSS(Cascading Style Sheet)188 'acronym': {189 pattern: /\b[A-Z\d]+\([^)]+\)/,190 inside: {191 'comment': {192 pattern: /(\()[^)]+(?=\))/,193 lookbehind: true194 },195 'punctuation': /[()]/196 }197 },198 // Prism(C)199 'mark': {200 pattern: /\b\((TM|R|C)\)/,201 alias: 'comment',202 inside: {203 'punctuation':/[()]/204 }205 }206 }207 }208 });209 var nestedPatterns = {210 'inline': Prism.util.clone(Prism.languages.textile['phrase'].inside['inline']),211 'link': Prism.util.clone(Prism.languages.textile['phrase'].inside['link']),212 'image': Prism.util.clone(Prism.languages.textile['phrase'].inside['image']),213 'footnote': Prism.util.clone(Prism.languages.textile['phrase'].inside['footnote']),214 'acronym': Prism.util.clone(Prism.languages.textile['phrase'].inside['acronym']),215 'mark': Prism.util.clone(Prism.languages.textile['phrase'].inside['mark'])216 };217 // Only allow alpha-numeric HTML tags, not XML tags218 Prism.languages.textile.tag.pattern = /<\/?(?!\d)[a-z0-9]+(?:\s+[^\s>\/=]+(?:=(?:("|')(?:\\\1|\\?(?!\1)[\w\W])*\1|[^\s'">=]+))?)*\s*\/?>/i;219 // Allow some nesting220 Prism.languages.textile['phrase'].inside['inline'].inside['bold'].inside = nestedPatterns;221 Prism.languages.textile['phrase'].inside['inline'].inside['italic'].inside = nestedPatterns;222 Prism.languages.textile['phrase'].inside['inline'].inside['inserted'].inside = nestedPatterns;223 Prism.languages.textile['phrase'].inside['inline'].inside['deleted'].inside = nestedPatterns;224 Prism.languages.textile['phrase'].inside['inline'].inside['span'].inside = nestedPatterns;225 // Allow some styles inside table cells226 Prism.languages.textile['phrase'].inside['table'].inside['inline'] = nestedPatterns['inline'];227 Prism.languages.textile['phrase'].inside['table'].inside['link'] = nestedPatterns['link'];228 Prism.languages.textile['phrase'].inside['table'].inside['image'] = nestedPatterns['image'];229 Prism.languages.textile['phrase'].inside['table'].inside['footnote'] = nestedPatterns['footnote'];230 Prism.languages.textile['phrase'].inside['table'].inside['acronym'] = nestedPatterns['acronym'];231 Prism.languages.textile['phrase'].inside['table'].inside['mark'] = nestedPatterns['mark'];...

Full Screen

Full Screen

util.js

Source:util.js Github

copy

Full Screen

1describe('zrUtil', function() {2 var utHelper = window.utHelper;3 var testCase = utHelper.prepare(['zrender/core/util']);4 describe('merge', function () {5 testCase('basic', function (zrUtil) {6 expect(zrUtil.merge({}, {a: 121})).toEqual({a: 121});7 expect(zrUtil.merge({a: 'zz'}, {a: '121'}, true)).toEqual({a: '121'});8 expect(zrUtil.merge({a: 'zz', b: {c: 1212}}, {b: {c: 'zxcv'}}, true)).toEqual({a: 'zz', b: {c: 'zxcv'}});9 });10 testCase('overwrite', function (zrUtil) {11 expect(zrUtil.merge({a: {b: 'zz'}}, {a: '121'}, true)).toEqual({a: '121'});12 expect(zrUtil.merge({a: null}, {a: '121'}, true)).toEqual({a: '121'});13 expect(zrUtil.merge({a: '12'}, {a: null}, true)).toEqual({a: null});14 expect(zrUtil.merge({a: {a: 'asdf'}}, {a: undefined}, true)).toEqual({a: undefined});15 var b = {b: 'vvv'}; // not same object16 var result = zrUtil.merge({a: null}, {a: b}, true);17 expect(result).toEqual({a: {b: 'vvv'}});18 expect(result.a === b).toEqual(false);19 });20 testCase('not_overwrite', function (zrUtil) {21 expect(zrUtil.merge({a: {b: 'zz'}}, {a: '121'}, false)).toEqual({a: {b: 'zz'}});22 expect(zrUtil.merge({a: null}, {a: '121'}, false)).toEqual({a: null});23 expect(zrUtil.merge({a: '12'}, {a: null}, false)).toEqual({a: '12'});24 expect(zrUtil.merge({a: {a: 'asdf'}}, {a: undefined}, false)).toEqual({a: {a: 'asdf'}});25 });26 testCase('array', function (zrUtil) {27 expect(zrUtil.merge({a: {a: 'asdf'}}, {a: ['asdf', 'zxcv']}, true)).toEqual({a: ['asdf', 'zxcv']});28 expect(zrUtil.merge({a: {a: [12, 23, 34]}}, {a: {a: [99, 88]}}, false)).toEqual({a: {a: [12, 23, 34]}});29 var b = [99, 88]; // not same object30 var result = zrUtil.merge({a: {a: [12, 23, 34]}}, {a: {a: b}}, true);31 expect(result).toEqual({a: {a: b}});32 expect(result.a.a === b).toEqual(false);33 });34 testCase('null_undefined', function (zrUtil) {35 expect(zrUtil.merge(null, {a: '121'})).toEqual(null);36 expect(zrUtil.merge(undefined, {a: '121'})).toEqual(undefined);37 expect(zrUtil.merge({a: '121'}, null)).toEqual({a: '121'});38 expect(zrUtil.merge({a: '121'}, undefined)).toEqual({a: '121'});39 });40 });41 describe('clone', function () {42 testCase('primary', function (zrUtil) {43 expect(zrUtil.clone(null)).toEqual(null);44 expect(zrUtil.clone(undefined)).toEqual(undefined);45 expect(zrUtil.clone(11)).toEqual(11);46 expect(zrUtil.clone('11')).toEqual('11');47 expect(zrUtil.clone('aa')).toEqual('aa');48 });49 testCase('array', function (zrUtil) {50 var ins;51 exp(52 zrUtil.clone(ins = [1, '2', 'a', 4, {x: 'r', y: [2, 3]}]),53 [1, '2', 'a', 4, {x: 'r', y: [2, 3]}],54 ins55 );56 exp(57 zrUtil.clone(ins = {a: [1, '2', 'a', 4, {x: 'r', y: [2, 3]}]}).a,58 [1, '2', 'a', 4, {x: 'r', y: [2, 3]}],59 ins60 );61 exp(62 zrUtil.clone(ins = {a: [1, [1, '2', 'a', 4, {x: 'r', y: [2, 3]}]]}).a[1],63 [1, '2', 'a', 4, {x: 'r', y: [2, 3]}],64 ins65 );66 function exp(cloned, target, source) {67 expect(cloned).toEqual(target) && source !== source;68 }69 });70 testCase('object', function (zrUtil) {71 var ins;72 exp(73 zrUtil.clone(ins = {x: 1, y: [2, 3], z: {a: 3}}),74 {x: 1, y: [2, 3], z: {a: 3}},75 ins76 );77 exp(78 zrUtil.clone(ins = {a: {x: 1, y: [2, 3], z: {a: 3}}}).a,79 {x: 1, y: [2, 3], z: {a: 3}},80 ins81 );82 exp(83 zrUtil.clone(ins = {a: [1, {x: 1, y: [2, 3], z: {a: 3}}]}).a[1],84 {x: 1, y: [2, 3], z: {a: 3}},85 ins86 );87 function exp(cloned, target, source) {88 expect(cloned).toEqual(target) && source !== source;89 }90 });91 testCase('built-in', function (zrUtil) {92 var source = [93 new Date(),94 function () {},95 /asdf/,96 new Error(),97 new Image(),98 document.createElement('canvas').getContext('2d').createLinearGradient(0, 0, 0, 0),99 document.createElement('canvas').getContext('2d').createPattern(new Image(), 'repeat')100 ];101 for (var i = 0; i < source.length; i++) {102 var d = source[i];103 expect(zrUtil.clone(d) === d).toEqual(true);104 expect(zrUtil.clone({a: d}).a === d).toEqual(true);105 expect(zrUtil.clone({a: [1, d]}).a[1] === d).toEqual(true);106 }107 });108 testCase('TypedArray', function (zrUtil) {109 var types = [110 Int8Array,111 Uint8Array,112 Uint8ClampedArray,113 Int16Array,114 Uint16Array,115 Int32Array,116 Uint32Array,117 Float32Array,118 Float64Array119 ];120 for (var i = 0; i < types.length; i++) {121 var d = new types[i](3);122 d[0] = 1;123 d[2] = 2;124 expect(typedArrayExpect(d, zrUtil.clone(d))).toEqual(true);125 expect(typedArrayExpect(d, zrUtil.clone({a: d}).a)).toEqual(true);126 expect(typedArrayExpect(d, zrUtil.clone({a: [1, d]}).a[1])).toEqual(true);127 }128 function typedArrayExpect(a, b) {129 if (a === b) {130 return false;131 }132 var typeStrA = Object.prototype.toString.call(a);133 var typeStrB = Object.prototype.toString.call(b);134 if (typeStrA !== typeStrB || a.length !== b.length) {135 return false;136 }137 for (var i = 0; i < a.length; i++) {138 if (a[i] !== b[i]) {139 return false;140 }141 }142 return true;143 }144 });145 testCase('user_defined_class', function (zrUtil) {146 var Clz = function (v) {147 this.bb = v;148 };149 Clz.prototype.aa = 1;150 var ins;151 exp(zrUtil.clone(ins = new Clz(2)), {bb: 2}, ins);152 exp(zrUtil.clone(ins = {a: new Clz(2)}).a, {bb: 2}, ins);153 exp(zrUtil.clone(ins = {a: [1, new Clz(2)]}).a[1], {bb: 2}, ins);154 function exp(cloned, target, source) {155 expect(cloned).toEqual(target) && source !== source;156 }157 });158 });...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1var clone = require('sinon').util.clone;2var extend = require('sinon').util.extend;3var times = require('sinon').util.times;4var functionName = require('sinon').util.functionName;5var value = require('sinon').util.value;6var wrapMethod = require('sinon').util.wrapMethod;7var call = require('sinon').util.call;8var callback = require('sinon').util.callback;9var nextTick = require('sinon').util.nextTick;10var every = require('sinon').util.every;11var some = require('sinon').util.some;12var isDate = require('sinon').util.isDate;13var isRestorable = require('sinon').util.isRestorable;14var isSinonProxy = require('sinon').util.isSinonProxy;15var isSinonProperty = require('sinon').util.isSinonProperty;16var isStub = require('sinon').util.isStub;17var isSpy = require('sinon').util.isSpy;18var isMatcher = require('sinon').util.isMatcher;19var isFunction = require('sinon').util.isFunction;20var isValue = require('sinon').util.isValue;21var functionToString = require('sinon

Full Screen

Using AI Code Generation

copy

Full Screen

1var n = require('sinon');2var obj = {a:1,b:2,c:3};3var clonedObj = n.util.clone(obj);4console.log(clonedObj);5{ a: 1, b: 2, c: 3 }6var n = require('sinon');7var obj = {a:1,b:2,c:3};8var obj2 = {d:4,e:5,f:6};9var clonedObj = n.util.extend(obj,obj2);10console.log(clonedObj);11{ a: 1, b: 2, c: 3, d: 4, e: 5, f: 6 }12var n = require('sinon');13var obj = {a:1,b:2,c:3};14var clonedObj = n.util.format('The value of a is %d',obj.a);15console.log(clonedObj);16var n = require('sinon');17var obj = {a:1,b:2,c:3};18var clonedObj = n.util.functionName(obj);19console.log(clonedObj);20var n = require('sinon');21var obj = function(){return 'hello'};22var clonedObj = n.util.functionName(obj);23console.log(clonedObj);24var n = require('sinon');25var obj = function(){return 'hello'};26var clonedObj = n.util.functionName(obj);27console.log(clonedObj);28var n = require('sinon');29var obj = function(){return 'hello'};30var clonedObj = n.util.functionName(obj);31console.log(clonedObj);32var n = require('sinon');

Full Screen

Using AI Code Generation

copy

Full Screen

1var n = require('sinon');2var obj = {a:1, b:2};3var clonedObj = n.util.clone(obj);4console.log(clonedObj);5var n = require('sinon');6var obj = {a:1, b:2};7var clonedObj = n.util.clone(obj);8console.log(clonedObj);9var n = require('sinon');10var obj = {a:1, b:2};11var clonedObj = n.util.clone(obj);12console.log(clonedObj);13var n = require('sinon');14var obj = {a:1, b:2};15var clonedObj = n.util.clone(obj);16console.log(clonedObj);17var n = require('sinon');18var obj = {a:1, b:2};19var clonedObj = n.util.clone(obj);20console.log(clonedObj);21var n = require('sinon');22var obj = {a:1, b:2};23var clonedObj = n.util.clone(obj);24console.log(clonedObj);25var n = require('sinon');26var obj = {a:1, b:2};27var clonedObj = n.util.clone(obj);28console.log(clonedObj);29var n = require('sinon');30var obj = {a:1, b:2};31var clonedObj = n.util.clone(obj);32console.log(clonedObj);33var n = require('sinon');34var obj = {a:1, b:2};35var clonedObj = n.util.clone(obj);36console.log(clonedObj);

Full Screen

Using AI Code Generation

copy

Full Screen

1var n = require('sinon');2var a = {a:1};3var b = n.util.clone(a);4var n = require('sinon');5var a = {a:1};6var b = n.util.clone(a);7var n = require('sinon');8var a = {a:1};9var b = {a:1};10var n = require('sinon');11function test() {}12var n = require('sinon');13function test() {}14var n = require('sinon');15var a = {a:1};16var b = sinon.spy();17var n = require('sinon');18var a = {a:1};19var n = require('sinon');20var a = {a:1};21var b = sinon.spy();22var n = require('sinon');23var a = {a:1};24var b = sinon.spy();25var n = require('sinon');26var a = {a:1

Full Screen

Using AI Code Generation

copy

Full Screen

1var clone = require('sinon').util.clone;2var cloneObj = clone(obj);3var deepEqual = require('sinon').util.deepEqual;4var isEqual = deepEqual(obj1, obj2);5var functionName = require('sinon').util.functionName;6var name = functionName(obj);7var functionToString = require('sinon').util.functionToString;8var fn = functionToString(obj);9var isArguments = require('sinon').util.isArguments;10var isArg = isArguments(obj);11var isArray = require('sinon').util.isArray;12var isArr = isArray(obj);13var isBoolean = require('sinon').util.isBoolean;14var isBool = isBoolean(obj);15var isDate = require('sinon').util.isDate;16var isDt = isDate(obj);17var isElement = require('sinon').util.isElement;18var isEl = isElement(obj);19var isFunction = require('sinon').util.isFunction;20var isFn = isFunction(obj);21var isMap = require('sinon').util.isMap;22var isMp = isMap(obj);23var isNumber = require('sinon').util.isNumber;24var isNum = isNumber(obj);25var isObject = require('sinon').util.isObject;26var isObj = isObject(obj);

Full Screen

Using AI Code Generation

copy

Full Screen

1var sinon = require("sinon");2var n = require("sinon/util/core");3var obj = {foo: "bar"};4var obj2 = n.util.clone(obj);5console.log(obj2);6console.log(obj2 === obj);7var sinon = require("sinon");8var n = require("sinon/util/core");9var obj = {foo: "bar"};10var obj2 = {foo: "bar"};11console.log(n.util.deepEquals(obj, obj2));12var sinon = require("sinon");13var n = require("sinon/util/core");14var obj = {foo: "bar"};15console.log(n.util.functionName(obj));16var fn = function () {};17console.log(n.util.functionName(fn));18var sinon = require("sinon");19var n = require("sinon/util/core");20var obj = {foo: "bar"};21console.log(n.util.isArray(obj));22var arr = ["foo", "bar"];23console.log(n.util.isArray(arr));24var sinon = require("sinon");25var n = require("sinon/util/core");26var obj = {foo: "bar"};27console.log(n.util.isDate(obj));28var date = new Date();29console.log(n.util.isDate(date));30var sinon = require("sinon");31var n = require("sinon/util/core");32var obj = {foo: "bar"};33console.log(n.util.isElement(obj));34var el = document.createElement("div");35console.log(n.util.isElement(el));36var sinon = require("sinon");37var n = require("sinon/util/core");38var obj = {foo: "bar"};39console.log(n.util.isFunction(obj));40var fn = function () {};41console.log(n.util.isFunction(fn

Full Screen

Using AI Code Generation

copy

Full Screen

1var n = require('sinon');2var obj1 = { name: 'foo', age: 27 };3var obj2 = { name: 'foo', age: 27 };4var obj3 = { name: 'foo', age: 27 };5var cloneObj1 = n.util.clone(obj1);6var cloneObj2 = n.util.clone(obj2);7var cloneObj3 = n.util.clone(obj3);

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 sinon 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