Best JavaScript code snippet using fast-check-monorepo
array-indexing-receiver.js
Source:array-indexing-receiver.js
...15 var array = [r, s, p];16 assertTrue(%HasObjectElements(array));17 assertFalse(%HasHoleyElements(array));18 for (var i = 0; i < kIterCount; ++i) {19 assertEquals(array.indexOf(p), 2);20 assertEquals(array.indexOf(o), -1);21 }22 },23 HOLEY_ELEMENTS() {24 var r = /foo/;25 var p = new Proxy({}, {});26 var o = {};27 var array = [r, , p];28 assertTrue(%HasObjectElements(array));29 assertTrue(%HasHoleyElements(array));30 for (var i = 0; i < kIterCount; ++i) {31 assertEquals(array.indexOf(p), 2);32 assertEquals(array.indexOf(o), -1);33 }34 },35 PACKED_SMI_ELEMENTS() {36 var array = [0, 88, 9999, 1, -5, 7];37 assertTrue(%HasSmiElements(array));38 assertFalse(%HasHoleyElements(array));39 for (var i = 0; i < kIterCount; ++i) {40 assertEquals(array.indexOf(9999), 2);41 assertEquals(array.indexOf(-5), 4);42 assertEquals(array.indexOf(-5.00001), -1);43 assertEquals(array.indexOf(undefined), -1);44 assertEquals(array.indexOf(NaN), -1);45 }46 },47 HOLEY_SMI_ELEMENTS() {48 var array = [49, , , 72, , , 67, -48];49 assertTrue(%HasSmiElements(array));50 assertTrue(%HasHoleyElements(array));51 for (var i = 0; i < kIterCount; ++i) {52 assertEquals(array.indexOf(72), 3);53 assertEquals(array.indexOf(-48), 7);54 assertEquals(array.indexOf(72, 4), -1);55 assertEquals(array.indexOf(undefined), -1);56 assertEquals(array.indexOf(undefined, -2), -1);57 assertEquals(array.indexOf(NaN), -1);58 }59 },60 PACKED_DOUBLE_ELEMENTS() {61 var array = [7.00000001, -13000.89412, 73451.4124,62 5824.48, 6.0000495, 48.3488, 44.0, 76.35, NaN, 78.4];63 assertTrue(%HasDoubleElements(array));64 assertFalse(%HasHoleyElements(array));65 for (var i = 0; i < kIterCount; ++i) {66 assertEquals(array.indexOf(7.00000001), 0);67 assertEquals(array.indexOf(7.00000001, 2), -1);68 assertEquals(array.indexOf(NaN), -1);69 assertEquals(array.indexOf(NaN, -1), -1);70 assertEquals(array.indexOf(-13000.89412), 1);71 assertEquals(array.indexOf(-13000.89412, -2), -1);72 assertEquals(array.indexOf(undefined), -1);73 }74 },75 HOLEY_DOUBLE_ELEMENTS() {76 var array = [7.00000001, -13000.89412, ,77 5824.48, , 48.3488, , NaN, , 78.4];78 assertTrue(%HasDoubleElements(array));79 assertTrue(%HasHoleyElements(array));80 for (var i = 0; i < kIterCount; ++i) {81 assertEquals(array.indexOf(7.00000001), 0);82 assertEquals(array.indexOf(7.00000001, 2), -1);83 assertEquals(array.indexOf(NaN), -1);84 assertEquals(array.indexOf(NaN, -2), -1);85 assertEquals(array.indexOf(-13000.89412), 1);86 assertEquals(array.indexOf(-13000.89412, -2), -1);87 assertEquals(array.indexOf(undefined, -2), -1);88 assertEquals(array.indexOf(undefined, -1), -1);89 }90 },91 DICTIONARY_ELEMENTS() {92 var array = [];93 Object.defineProperty(array, 4, { get() { gc(); return NaN; } });94 Object.defineProperty(array, 7, { value: Function });95 assertTrue(%HasDictionaryElements(array));96 for (var i = 0; i < kIterCount; ++i) {97 assertEquals(array.indexOf(NaN), -1);98 assertEquals(array.indexOf(NaN, -3), -1);99 assertEquals(array.indexOf(Function), 7);100 assertEquals(array.indexOf(undefined), -1);101 assertEquals(array.indexOf(undefined, 7), -1);102 }103 },104 },105 Object: {106 PACKED_ELEMENTS() {107 var r = /foo/;108 var s = new String("bar");109 var p = new Proxy({}, {});110 var o = {};111 var object = { 0: r, 1: s, 2: p, length: 3 };112 assertTrue(%HasObjectElements(object));113 // TODO(caitp): JSObjects always seem to start with HOLEY_ELEMENTS114 // assertFalse(%HasHoleyElements(object));115 for (var i = 0; i < kIterCount; ++i) {...
indexOf.js
Source:indexOf.js
...3const BufferList = require('../')4const { Buffer } = require('buffer')5tape('indexOf single byte needle', (t) => {6 const bl = new BufferList(['abcdefg', 'abcdefg', '12345'])7 t.equal(bl.indexOf('e'), 4)8 t.equal(bl.indexOf('e', 5), 11)9 t.equal(bl.indexOf('e', 12), -1)10 t.equal(bl.indexOf('5'), 18)11 t.end()12})13tape('indexOf multiple byte needle', (t) => {14 const bl = new BufferList(['abcdefg', 'abcdefg'])15 t.equal(bl.indexOf('ef'), 4)16 t.equal(bl.indexOf('ef', 5), 11)17 t.end()18})19tape('indexOf multiple byte needles across buffer boundaries', (t) => {20 const bl = new BufferList(['abcdefg', 'abcdefg'])21 t.equal(bl.indexOf('fgabc'), 5)22 t.end()23})24tape('indexOf takes a Uint8Array search', (t) => {25 const bl = new BufferList(['abcdefg', 'abcdefg'])26 const search = new Uint8Array([102, 103, 97, 98, 99]) // fgabc27 t.equal(bl.indexOf(search), 5)28 t.end()29})30tape('indexOf takes a buffer list search', (t) => {31 const bl = new BufferList(['abcdefg', 'abcdefg'])32 const search = new BufferList('fgabc')33 t.equal(bl.indexOf(search), 5)34 t.end()35})36tape('indexOf a zero byte needle', (t) => {37 const b = new BufferList('abcdef')38 const bufEmpty = Buffer.from('')39 t.equal(b.indexOf(''), 0)40 t.equal(b.indexOf('', 1), 1)41 t.equal(b.indexOf('', b.length + 1), b.length)42 t.equal(b.indexOf('', Infinity), b.length)43 t.equal(b.indexOf(bufEmpty), 0)44 t.equal(b.indexOf(bufEmpty, 1), 1)45 t.equal(b.indexOf(bufEmpty, b.length + 1), b.length)46 t.equal(b.indexOf(bufEmpty, Infinity), b.length)47 t.end()48})49tape('indexOf buffers smaller and larger than the needle', (t) => {50 const bl = new BufferList(['abcdefg', 'a', 'bcdefg', 'a', 'bcfgab'])51 t.equal(bl.indexOf('fgabc'), 5)52 t.equal(bl.indexOf('fgabc', 6), 12)53 t.equal(bl.indexOf('fgabc', 13), -1)54 t.end()55})56// only present in node 6+57;(process.version.substr(1).split('.')[0] >= 6) && tape('indexOf latin1 and binary encoding', (t) => {58 const b = new BufferList('abcdef')59 // test latin1 encoding60 t.equal(61 new BufferList(Buffer.from(b.toString('latin1'), 'latin1'))62 .indexOf('d', 0, 'latin1'),63 364 )65 t.equal(66 new BufferList(Buffer.from(b.toString('latin1'), 'latin1'))67 .indexOf(Buffer.from('d', 'latin1'), 0, 'latin1'),68 369 )70 t.equal(71 new BufferList(Buffer.from('aa\u00e8aa', 'latin1'))72 .indexOf('\u00e8', 'latin1'),73 274 )75 t.equal(76 new BufferList(Buffer.from('\u00e8', 'latin1'))77 .indexOf('\u00e8', 'latin1'),78 079 )80 t.equal(81 new BufferList(Buffer.from('\u00e8', 'latin1'))82 .indexOf(Buffer.from('\u00e8', 'latin1'), 'latin1'),83 084 )85 // test binary encoding86 t.equal(87 new BufferList(Buffer.from(b.toString('binary'), 'binary'))88 .indexOf('d', 0, 'binary'),89 390 )91 t.equal(92 new BufferList(Buffer.from(b.toString('binary'), 'binary'))93 .indexOf(Buffer.from('d', 'binary'), 0, 'binary'),94 395 )96 t.equal(97 new BufferList(Buffer.from('aa\u00e8aa', 'binary'))98 .indexOf('\u00e8', 'binary'),99 2100 )101 t.equal(102 new BufferList(Buffer.from('\u00e8', 'binary'))103 .indexOf('\u00e8', 'binary'),104 0105 )106 t.equal(107 new BufferList(Buffer.from('\u00e8', 'binary'))108 .indexOf(Buffer.from('\u00e8', 'binary'), 'binary'),109 0110 )111 t.end()112})113tape('indexOf the entire nodejs10 buffer test suite', (t) => {114 const b = new BufferList('abcdef')115 const bufA = Buffer.from('a')116 const bufBc = Buffer.from('bc')117 const bufF = Buffer.from('f')118 const bufZ = Buffer.from('z')119 const stringComparison = 'abcdef'120 t.equal(b.indexOf('a'), 0)121 t.equal(b.indexOf('a', 1), -1)122 t.equal(b.indexOf('a', -1), -1)123 t.equal(b.indexOf('a', -4), -1)124 t.equal(b.indexOf('a', -b.length), 0)125 t.equal(b.indexOf('a', NaN), 0)126 t.equal(b.indexOf('a', -Infinity), 0)127 t.equal(b.indexOf('a', Infinity), -1)128 t.equal(b.indexOf('bc'), 1)129 t.equal(b.indexOf('bc', 2), -1)130 t.equal(b.indexOf('bc', -1), -1)131 t.equal(b.indexOf('bc', -3), -1)132 t.equal(b.indexOf('bc', -5), 1)133 t.equal(b.indexOf('bc', NaN), 1)134 t.equal(b.indexOf('bc', -Infinity), 1)135 t.equal(b.indexOf('bc', Infinity), -1)136 t.equal(b.indexOf('f'), b.length - 1)137 t.equal(b.indexOf('z'), -1)138 // empty search tests139 t.equal(b.indexOf(bufA), 0)140 t.equal(b.indexOf(bufA, 1), -1)141 t.equal(b.indexOf(bufA, -1), -1)142 t.equal(b.indexOf(bufA, -4), -1)143 t.equal(b.indexOf(bufA, -b.length), 0)144 t.equal(b.indexOf(bufA, NaN), 0)145 t.equal(b.indexOf(bufA, -Infinity), 0)146 t.equal(b.indexOf(bufA, Infinity), -1)147 t.equal(b.indexOf(bufBc), 1)148 t.equal(b.indexOf(bufBc, 2), -1)149 t.equal(b.indexOf(bufBc, -1), -1)150 t.equal(b.indexOf(bufBc, -3), -1)151 t.equal(b.indexOf(bufBc, -5), 1)152 t.equal(b.indexOf(bufBc, NaN), 1)153 t.equal(b.indexOf(bufBc, -Infinity), 1)154 t.equal(b.indexOf(bufBc, Infinity), -1)155 t.equal(b.indexOf(bufF), b.length - 1)156 t.equal(b.indexOf(bufZ), -1)157 t.equal(b.indexOf(0x61), 0)158 t.equal(b.indexOf(0x61, 1), -1)159 t.equal(b.indexOf(0x61, -1), -1)160 t.equal(b.indexOf(0x61, -4), -1)161 t.equal(b.indexOf(0x61, -b.length), 0)162 t.equal(b.indexOf(0x61, NaN), 0)163 t.equal(b.indexOf(0x61, -Infinity), 0)164 t.equal(b.indexOf(0x61, Infinity), -1)165 t.equal(b.indexOf(0x0), -1)166 // test offsets167 t.equal(b.indexOf('d', 2), 3)168 t.equal(b.indexOf('f', 5), 5)169 t.equal(b.indexOf('f', -1), 5)170 t.equal(b.indexOf('f', 6), -1)171 t.equal(b.indexOf(Buffer.from('d'), 2), 3)172 t.equal(b.indexOf(Buffer.from('f'), 5), 5)173 t.equal(b.indexOf(Buffer.from('f'), -1), 5)174 t.equal(b.indexOf(Buffer.from('f'), 6), -1)175 t.equal(Buffer.from('ff').indexOf(Buffer.from('f'), 1, 'ucs2'), -1)176 // test invalid and uppercase encoding177 t.equal(b.indexOf('b', 'utf8'), 1)178 t.equal(b.indexOf('b', 'UTF8'), 1)179 t.equal(b.indexOf('62', 'HEX'), 1)180 t.throws(() => b.indexOf('bad', 'enc'), TypeError)181 // test hex encoding182 t.equal(183 Buffer.from(b.toString('hex'), 'hex')184 .indexOf('64', 0, 'hex'),185 3186 )187 t.equal(188 Buffer.from(b.toString('hex'), 'hex')189 .indexOf(Buffer.from('64', 'hex'), 0, 'hex'),190 3191 )192 // test base64 encoding193 t.equal(194 Buffer.from(b.toString('base64'), 'base64')195 .indexOf('ZA==', 0, 'base64'),196 3197 )198 t.equal(199 Buffer.from(b.toString('base64'), 'base64')200 .indexOf(Buffer.from('ZA==', 'base64'), 0, 'base64'),201 3202 )203 // test ascii encoding204 t.equal(205 Buffer.from(b.toString('ascii'), 'ascii')206 .indexOf('d', 0, 'ascii'),207 3208 )209 t.equal(210 Buffer.from(b.toString('ascii'), 'ascii')211 .indexOf(Buffer.from('d', 'ascii'), 0, 'ascii'),212 3213 )214 // test optional offset with passed encoding215 t.equal(Buffer.from('aaaa0').indexOf('30', 'hex'), 4)216 t.equal(Buffer.from('aaaa00a').indexOf('3030', 'hex'), 4)217 {218 // test usc2 encoding219 const twoByteString = Buffer.from('\u039a\u0391\u03a3\u03a3\u0395', 'ucs2')220 t.equal(8, twoByteString.indexOf('\u0395', 4, 'ucs2'))221 t.equal(6, twoByteString.indexOf('\u03a3', -4, 'ucs2'))222 t.equal(4, twoByteString.indexOf('\u03a3', -6, 'ucs2'))223 t.equal(4, twoByteString.indexOf(224 Buffer.from('\u03a3', 'ucs2'), -6, 'ucs2'))225 t.equal(-1, twoByteString.indexOf('\u03a3', -2, 'ucs2'))226 }227 const mixedByteStringUcs2 =228 Buffer.from('\u039a\u0391abc\u03a3\u03a3\u0395', 'ucs2')229 t.equal(6, mixedByteStringUcs2.indexOf('bc', 0, 'ucs2'))230 t.equal(10, mixedByteStringUcs2.indexOf('\u03a3', 0, 'ucs2'))231 t.equal(-1, mixedByteStringUcs2.indexOf('\u0396', 0, 'ucs2'))232 t.equal(233 6, mixedByteStringUcs2.indexOf(Buffer.from('bc', 'ucs2'), 0, 'ucs2'))234 t.equal(235 10, mixedByteStringUcs2.indexOf(Buffer.from('\u03a3', 'ucs2'), 0, 'ucs2'))236 t.equal(237 -1, mixedByteStringUcs2.indexOf(Buffer.from('\u0396', 'ucs2'), 0, 'ucs2'))238 {239 const twoByteString = Buffer.from('\u039a\u0391\u03a3\u03a3\u0395', 'ucs2')240 // Test single char pattern241 t.equal(0, twoByteString.indexOf('\u039a', 0, 'ucs2'))242 let index = twoByteString.indexOf('\u0391', 0, 'ucs2')243 t.equal(2, index, `Alpha - at index ${index}`)244 index = twoByteString.indexOf('\u03a3', 0, 'ucs2')245 t.equal(4, index, `First Sigma - at index ${index}`)246 index = twoByteString.indexOf('\u03a3', 6, 'ucs2')247 t.equal(6, index, `Second Sigma - at index ${index}`)248 index = twoByteString.indexOf('\u0395', 0, 'ucs2')249 t.equal(8, index, `Epsilon - at index ${index}`)250 index = twoByteString.indexOf('\u0392', 0, 'ucs2')251 t.equal(-1, index, `Not beta - at index ${index}`)252 // Test multi-char pattern253 index = twoByteString.indexOf('\u039a\u0391', 0, 'ucs2')254 t.equal(0, index, `Lambda Alpha - at index ${index}`)255 index = twoByteString.indexOf('\u0391\u03a3', 0, 'ucs2')256 t.equal(2, index, `Alpha Sigma - at index ${index}`)257 index = twoByteString.indexOf('\u03a3\u03a3', 0, 'ucs2')258 t.equal(4, index, `Sigma Sigma - at index ${index}`)259 index = twoByteString.indexOf('\u03a3\u0395', 0, 'ucs2')260 t.equal(6, index, `Sigma Epsilon - at index ${index}`)261 }262 const mixedByteStringUtf8 = Buffer.from('\u039a\u0391abc\u03a3\u03a3\u0395')263 t.equal(5, mixedByteStringUtf8.indexOf('bc'))264 t.equal(5, mixedByteStringUtf8.indexOf('bc', 5))265 t.equal(5, mixedByteStringUtf8.indexOf('bc', -8))266 t.equal(7, mixedByteStringUtf8.indexOf('\u03a3'))267 t.equal(-1, mixedByteStringUtf8.indexOf('\u0396'))268 // Test complex string indexOf algorithms. Only trigger for long strings.269 // Long string that isn't a simple repeat of a shorter string.270 let longString = 'A'271 for (let i = 66; i < 76; i++) { // from 'B' to 'K'272 longString = longString + String.fromCharCode(i) + longString273 }274 const longBufferString = Buffer.from(longString)275 // pattern of 15 chars, repeated every 16 chars in long276 let pattern = 'ABACABADABACABA'277 for (let i = 0; i < longBufferString.length - pattern.length; i += 7) {278 const index = longBufferString.indexOf(pattern, i)279 t.equal((i + 15) & ~0xf, index,280 `Long ABACABA...-string at index ${i}`)281 }282 let index = longBufferString.indexOf('AJABACA')283 t.equal(510, index, `Long AJABACA, First J - at index ${index}`)284 index = longBufferString.indexOf('AJABACA', 511)285 t.equal(1534, index, `Long AJABACA, Second J - at index ${index}`)286 pattern = 'JABACABADABACABA'287 index = longBufferString.indexOf(pattern)288 t.equal(511, index, `Long JABACABA..., First J - at index ${index}`)289 index = longBufferString.indexOf(pattern, 512)290 t.equal(291 1535, index, `Long JABACABA..., Second J - at index ${index}`)292 // Search for a non-ASCII string in a pure ASCII string.293 const asciiString = Buffer.from(294 'somethingnotatallsinisterwhichalsoworks')295 t.equal(-1, asciiString.indexOf('\x2061'))296 t.equal(3, asciiString.indexOf('eth', 0))297 // Search in string containing many non-ASCII chars.298 const allCodePoints = []299 for (let i = 0; i < 65536; i++) {300 allCodePoints[i] = i301 }302 const allCharsString = String.fromCharCode.apply(String, allCodePoints)303 const allCharsBufferUtf8 = Buffer.from(allCharsString)304 const allCharsBufferUcs2 = Buffer.from(allCharsString, 'ucs2')305 // Search for string long enough to trigger complex search with ASCII pattern306 // and UC16 subject.307 t.equal(-1, allCharsBufferUtf8.indexOf('notfound'))308 t.equal(-1, allCharsBufferUcs2.indexOf('notfound'))309 // Needle is longer than haystack, but only because it's encoded as UTF-16310 t.equal(Buffer.from('aaaa').indexOf('a'.repeat(4), 'ucs2'), -1)311 t.equal(Buffer.from('aaaa').indexOf('a'.repeat(4), 'utf8'), 0)312 t.equal(Buffer.from('aaaa').indexOf('ä½ å¥½', 'ucs2'), -1)313 // Haystack has odd length, but the needle is UCS2.314 t.equal(Buffer.from('aaaaa').indexOf('b', 'ucs2'), -1)315 {316 // Find substrings in Utf8.317 const lengths = [1, 3, 15] // Single char, simple and complex.318 const indices = [0x5, 0x60, 0x400, 0x680, 0x7ee, 0xFF02, 0x16610, 0x2f77b]319 for (let lengthIndex = 0; lengthIndex < lengths.length; lengthIndex++) {320 for (let i = 0; i < indices.length; i++) {321 const index = indices[i]322 let length = lengths[lengthIndex]323 if (index + length > 0x7F) {324 length = 2 * length325 }326 if (index + length > 0x7FF) {327 length = 3 * length328 }329 if (index + length > 0xFFFF) {330 length = 4 * length331 }332 const patternBufferUtf8 = allCharsBufferUtf8.slice(index, index + length)333 t.equal(index, allCharsBufferUtf8.indexOf(patternBufferUtf8))334 const patternStringUtf8 = patternBufferUtf8.toString()335 t.equal(index, allCharsBufferUtf8.indexOf(patternStringUtf8))336 }337 }338 }339 {340 // Find substrings in Usc2.341 const lengths = [2, 4, 16] // Single char, simple and complex.342 const indices = [0x5, 0x65, 0x105, 0x205, 0x285, 0x2005, 0x2085, 0xfff0]343 for (let lengthIndex = 0; lengthIndex < lengths.length; lengthIndex++) {344 for (let i = 0; i < indices.length; i++) {345 const index = indices[i] * 2346 const length = lengths[lengthIndex]347 const patternBufferUcs2 =348 allCharsBufferUcs2.slice(index, index + length)349 t.equal(350 index, allCharsBufferUcs2.indexOf(patternBufferUcs2, 0, 'ucs2'))351 const patternStringUcs2 = patternBufferUcs2.toString('ucs2')352 t.equal(353 index, allCharsBufferUcs2.indexOf(patternStringUcs2, 0, 'ucs2'))354 }355 }356 }357 [358 () => {},359 {},360 []361 ].forEach((val) => {362 t.throws(() => b.indexOf(val), TypeError, `"${JSON.stringify(val)}" should throw`)363 })364 // Test weird offset arguments.365 // The following offsets coerce to NaN or 0, searching the whole Buffer366 t.equal(b.indexOf('b', undefined), 1)367 t.equal(b.indexOf('b', {}), 1)368 t.equal(b.indexOf('b', 0), 1)369 t.equal(b.indexOf('b', null), 1)370 t.equal(b.indexOf('b', []), 1)371 // The following offset coerces to 2, in other words +[2] === 2372 t.equal(b.indexOf('b', [2]), -1)373 // Behavior should match String.indexOf()374 t.equal(375 b.indexOf('b', undefined),376 stringComparison.indexOf('b', undefined))377 t.equal(378 b.indexOf('b', {}),379 stringComparison.indexOf('b', {}))380 t.equal(381 b.indexOf('b', 0),382 stringComparison.indexOf('b', 0))383 t.equal(384 b.indexOf('b', null),385 stringComparison.indexOf('b', null))386 t.equal(387 b.indexOf('b', []),388 stringComparison.indexOf('b', []))389 t.equal(390 b.indexOf('b', [2]),391 stringComparison.indexOf('b', [2]))392 // test truncation of Number arguments to uint8393 {394 const buf = Buffer.from('this is a test')395 t.equal(buf.indexOf(0x6973), 3)396 t.equal(buf.indexOf(0x697320), 4)397 t.equal(buf.indexOf(0x69732069), 2)398 t.equal(buf.indexOf(0x697374657374), 0)399 t.equal(buf.indexOf(0x69737374), 0)400 t.equal(buf.indexOf(0x69737465), 11)401 t.equal(buf.indexOf(0x69737465), 11)402 t.equal(buf.indexOf(-140), 0)403 t.equal(buf.indexOf(-152), 1)404 t.equal(buf.indexOf(0xff), -1)405 t.equal(buf.indexOf(0xffff), -1)406 }407 // Test that Uint8Array arguments are okay.408 {409 const needle = new Uint8Array([0x66, 0x6f, 0x6f])410 const haystack = new BufferList(Buffer.from('a foo b foo'))411 t.equal(haystack.indexOf(needle), 2)412 }413 t.end()...
15.5.4.6-2.js
Source:15.5.4.6-2.js
...3 * 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/**6 File Name: 15.5.4.6-1.js7 ECMA Section: 15.5.4.6 String.prototype.indexOf( searchString, pos)8 Description: If the given searchString appears as a substring of the9 result of converting this object to a string, at one or10 more positions that are at or to the right of the11 specified position, then the index of the leftmost such12 position is returned; otherwise -1 is returned. If13 positionis undefined or not supplied, 0 is assumed, so14 as to search all of the string.15 When the indexOf method is called with two arguments,16 searchString and pos, the following steps are taken:17 1. Call ToString, giving it the this value as its18 argument.19 2. Call ToString(searchString).20 3. Call ToInteger(position). (If position is undefined21 or not supplied, this step produces the value 0).22 4. Compute the number of characters in Result(1).23 5. Compute min(max(Result(3), 0), Result(4)).24 6. Compute the number of characters in the string that25 is Result(2).26 7. Compute the smallest possible integer k not smaller27 than Result(5) such that k+Result(6) is not greater28 than Result(4), and for all nonnegative integers j29 less than Result(6), the character at position k+j30 of Result(1) is the same as the character at position31 j of Result(2); but if there is no such integer k,32 then compute the value -1.33 8. Return Result(7).34 Note that the indexOf function is intentionally generic;35 it does not require that its this value be a String object.36 Therefore it can be transferred to other kinds of objects37 for use as a method.38 Author: christine@netscape.com, pschwartau@netscape.com39 Date: 02 October 199740 Modified: 14 July 200241 Reason: See http://bugzilla.mozilla.org/show_bug.cgi?id=15528942 ECMA-262 Ed.3 Section 15.5.4.743 The length property of the indexOf method is 144 *45 */46var SECTION = "15.5.4.6-2";47var VERSION = "ECMA_1";48var TITLE = "String.protoype.indexOf";49var BUGNUMBER="105721";50startTest();51writeHeaderToLog( SECTION + " "+ TITLE);52// the following test regresses http://scopus/bugsplat/show_bug.cgi?id=10572153// regress http://scopus/bugsplat/show_bug.cgi?id=10572154new TestCase( SECTION,55 "function f() { return this; }; function g() { var h = f; return h(); }; g().toString()", 56 GLOBAL, 57 g().toString()58 );59new TestCase( SECTION, "String.prototype.indexOf.length", 1, String.prototype.indexOf.length );60new TestCase( SECTION, "String.prototype.indexOf.length = null; String.prototype.indexOf.length", 1, eval("String.prototype.indexOf.length = null; String.prototype.indexOf.length") );61new TestCase( SECTION,62 "var s = new String(); s.indexOf()", 63 -1, 64 eval("var s = new String(); s.indexOf()") );65// some Unicode tests.66// generate a test string.67var TEST_STRING = "";68for ( var u = 0x00A1; u <= 0x00FF; u++ ) {69 TEST_STRING += String.fromCharCode( u );70}71for ( var u = 0x00A1, i = 0; u <= 0x00FF; u++, i++ ) {72 new TestCase( SECTION,73 "TEST_STRING.indexOf( " + String.fromCharCode(u) + " )",74 i,75 TEST_STRING.indexOf( String.fromCharCode(u) ) );76}77for ( var u = 0x00A1, i = 0; u <= 0x00FF; u++, i++ ) {78 new TestCase( SECTION,79 "TEST_STRING.indexOf( " + String.fromCharCode(u) + ", void 0 )",80 i,81 TEST_STRING.indexOf( String.fromCharCode(u), void 0 ) );82}83var foo = new MyObject('hello');84new TestCase( SECTION, "var foo = new MyObject('hello');foo.indexOf('h')", 0, foo.indexOf("h") );85new TestCase( SECTION, "var foo = new MyObject('hello');foo.indexOf('e')", 1, foo.indexOf("e") );86new TestCase( SECTION, "var foo = new MyObject('hello');foo.indexOf('l')", 2, foo.indexOf("l") );87new TestCase( SECTION, "var foo = new MyObject('hello');foo.indexOf('l')", 2, foo.indexOf("l") );88new TestCase( SECTION, "var foo = new MyObject('hello');foo.indexOf('o')", 4, foo.indexOf("o") );89new TestCase( SECTION, "var foo = new MyObject('hello');foo.indexOf('X')", -1, foo.indexOf("X") );90new TestCase( SECTION, "var foo = new MyObject('hello');foo.indexOf(5) ", -1, foo.indexOf(5) );91var boo = new MyObject(true);92new TestCase( SECTION, "var boo = new MyObject(true);boo.indexOf('t')", 0, boo.indexOf("t") );93new TestCase( SECTION, "var boo = new MyObject(true);boo.indexOf('r')", 1, boo.indexOf("r") );94new TestCase( SECTION, "var boo = new MyObject(true);boo.indexOf('u')", 2, boo.indexOf("u") );95new TestCase( SECTION, "var boo = new MyObject(true);boo.indexOf('e')", 3, boo.indexOf("e") );96new TestCase( SECTION, "var boo = new MyObject(true);boo.indexOf('true')", 0, boo.indexOf("true") );97new TestCase( SECTION, "var boo = new MyObject(true);boo.indexOf('rue')", 1, boo.indexOf("rue") );98new TestCase( SECTION, "var boo = new MyObject(true);boo.indexOf('ue')", 2, boo.indexOf("ue") );99new TestCase( SECTION, "var boo = new MyObject(true);boo.indexOf('oy')", -1, boo.indexOf("oy") );100var noo = new MyObject( Math.PI );101new TestCase( SECTION, "var noo = new MyObject(Math.PI); noo.indexOf('3') ", 0, noo.indexOf('3') );102new TestCase( SECTION, "var noo = new MyObject(Math.PI); noo.indexOf('.') ", 1, noo.indexOf('.') );103new TestCase( SECTION, "var noo = new MyObject(Math.PI); noo.indexOf('1') ", 2, noo.indexOf('1') );104new TestCase( SECTION, "var noo = new MyObject(Math.PI); noo.indexOf('4') ", 3, noo.indexOf('4') );105new TestCase( SECTION, "var noo = new MyObject(Math.PI); noo.indexOf('1') ", 2, noo.indexOf('1') );106new TestCase( SECTION, "var noo = new MyObject(Math.PI); noo.indexOf('5') ", 5, noo.indexOf('5') );107new TestCase( SECTION, "var noo = new MyObject(Math.PI); noo.indexOf('9') ", 6, noo.indexOf('9') );108new TestCase( SECTION,109 "var arr = new Array('new','zoo','revue'); arr.indexOf = String.prototype.indexOf; arr.indexOf('new')",110 0,111 eval("var arr = new Array('new','zoo','revue'); arr.indexOf = String.prototype.indexOf; arr.indexOf('new')") );112new TestCase( SECTION,113 "var arr = new Array('new','zoo','revue'); arr.indexOf = String.prototype.indexOf; arr.indexOf(',zoo,')",114 3,115 eval("var arr = new Array('new','zoo','revue'); arr.indexOf = String.prototype.indexOf; arr.indexOf(',zoo,')") );116new TestCase( SECTION,117 "var obj = new Object(); obj.indexOf = String.prototype.indexOf; obj.indexOf('[object Object]')",118 0,119 eval("var obj = new Object(); obj.indexOf = String.prototype.indexOf; obj.indexOf('[object Object]')") );120new TestCase( SECTION,121 "var obj = new Object(); obj.indexOf = String.prototype.indexOf; obj.indexOf('bject')",122 2,123 eval("var obj = new Object(); obj.indexOf = String.prototype.indexOf; obj.indexOf('bject')") );124new TestCase( SECTION,125 "var f = new Function(); f.toString = Object.prototype.toString; f.indexOf = String.prototype.indexOf; f.indexOf('[object Function]')",126 0,127 eval("var f = new Function(); f.toString = Object.prototype.toString; f.indexOf = String.prototype.indexOf; f.indexOf('[object Function]')") );128new TestCase( SECTION,129 "var b = new Boolean(); b.indexOf = String.prototype.indexOf; b.indexOf('true')",130 -1,131 eval("var b = new Boolean(); b.indexOf = String.prototype.indexOf; b.indexOf('true')") );132new TestCase( SECTION,133 "var b = new Boolean(); b.indexOf = String.prototype.indexOf; b.indexOf('false', 1)",134 -1,135 eval("var b = new Boolean(); b.indexOf = String.prototype.indexOf; b.indexOf('false', 1)") );136new TestCase( SECTION,137 "var b = new Boolean(); b.indexOf = String.prototype.indexOf; b.indexOf('false', 0)",138 0,139 eval("var b = new Boolean(); b.indexOf = String.prototype.indexOf; b.indexOf('false', 0)") );140new TestCase( SECTION,141 "var n = new Number(1e21); n.indexOf = String.prototype.indexOf; n.indexOf('e')",142 1,143 eval("var n = new Number(1e21); n.indexOf = String.prototype.indexOf; n.indexOf('e')") );144new TestCase( SECTION,145 "var n = new Number(-Infinity); n.indexOf = String.prototype.indexOf; n.indexOf('-')",146 0,147 eval("var n = new Number(-Infinity); n.indexOf = String.prototype.indexOf; n.indexOf('-')") );148new TestCase( SECTION,149 "var n = new Number(0xFF); n.indexOf = String.prototype.indexOf; n.indexOf('5')",150 1,151 eval("var n = new Number(0xFF); n.indexOf = String.prototype.indexOf; n.indexOf('5')") );152new TestCase( SECTION,153 "var m = Math; m.indexOf = String.prototype.indexOf; m.indexOf( 'Math' )",154 8,155 eval("var m = Math; m.indexOf = String.prototype.indexOf; m.indexOf( 'Math' )") );156// new Date(0) has '31' or '01' at index 8 depending on whether tester is (GMT-) or (GMT+), respectively157new TestCase( SECTION,158 "var d = new Date(0); d.indexOf = String.prototype.indexOf; d.getTimezoneOffset()>0 ? d.indexOf('31') : d.indexOf('01')",159 8,160 eval("var d = new Date(0); d.indexOf = String.prototype.indexOf; d.getTimezoneOffset()>0 ? d.indexOf('31') : d.indexOf('01')") );161test();162function f() {163 return this;164}165function g() {166 var h = f;167 return h();168}169function MyObject (v) {170 this.value = v;171 this.toString = new Function ( "return this.value +\"\"");172 this.indexOf = String.prototype.indexOf;...
auto-detect-browserName.JS
Source:auto-detect-browserName.JS
1 var geckobrowsers;2 var browser = "";3 var agent = navigator.userAgent;4 if (agent.substring(agent.indexOf("Mozilla/") + 8, agent.indexOf(" ")) == "5.0" && agent.indexOf("like Gecko") != -1) {5 geckobrowsers = agent.substring(agent.indexOf("like Gecko") + 10).substring(agent.substring(agent.indexOf("like Gecko") + 10).indexOf(") ") + 2).replace("LG Browser", "LGBrowser").replace("360SE", "360SE/");6 for (i = 0; i < 1; i++) {7 geckobrowsers = geckobrowsers.replace(geckobrowsers.substring(geckobrowsers.indexOf("("), geckobrowsers.indexOf(")") + 1), "");8 }9 geckobrowsers = geckobrowsers.split(" ");10 for (i = 0; i < geckobrowsers.length; i++) {11 if (geckobrowsers[i].indexOf("/") == -1) geckobrowsers[i] = "Chrome";12 if (geckobrowsers[i].indexOf("/") != -1) geckobrowsers[i] = geckobrowsers[i].substring(0, geckobrowsers[i].indexOf("/"));13 }14 if (geckobrowsers.length < 4) {15 browser = geckobrowsers[0];16 } else {17 for (i = 0; i < geckobrowsers.length; i++) {18 if (geckobrowsers[i].indexOf("Chrome") == -1 && geckobrowsers[i].indexOf("Safari") == -1 && geckobrowsers[i].indexOf("Mobile") == -1 && geckobrowsers[i].indexOf("Version") == -1)19 browser = geckobrowsers[i];20 }21 }22 // browserVersion = agent.substring(agent.indexOf(browser)+browser.length+1, agent.indexOf(browser)+browser.length+1+agent.substring(agent.indexOf(browser)+browser.length+1).indexOf(" "));23 } else if (agent.substring(agent.indexOf("Mozilla/") + 8, agent.indexOf(" ")) == "5.0" && agent.indexOf("Gecko/") != -1) {24 browser = agent.substring(agent.substring(agent.indexOf("Gecko/") + 6).indexOf(" ") + agent.indexOf("Gecko/") + 6).substring(0, agent.substring(agent.substring(agent.indexOf("Gecko/") + 6).indexOf(" ") + agent.indexOf("Gecko/") + 6).indexOf("/"));25 } else if (agent.substring(agent.indexOf("Mozilla/") + 8, agent.indexOf(" ")) == "5.0" && agent.indexOf("Clecko/") != -1) {26 browser = agent.substring(agent.substring(agent.indexOf("Clecko/") + 7).indexOf(" ") + agent.indexOf("Clecko/") + 7).substring(0, agent.substring(agent.substring(agent.indexOf("Clecko/") + 7).indexOf(" ") + agent.indexOf("Clecko/") + 7).indexOf("/"));27 // browserVersion = agent.substring(agent.indexOf(browser)+browser.length+1, agent.indexOf(browser)+browser.length+1+agent.substring(agent.indexOf(browser)+browser.length+1).indexOf(" "));28 } else if (agent.substring(agent.indexOf("Mozilla/") + 8, agent.indexOf(" ")) == "5.0") {29 browser = agent.substring(agent.indexOf("(") + 1, agent.indexOf(";"));30 // browserVersion = agent.substring(agent.indexOf(browser)+browser.length+1, agent.indexOf(browser)+browser.length+1+agent.substring(agent.indexOf(browser)+browser.length+1).indexOf(" "));31 } else if (agent.substring(agent.indexOf("Mozilla/") + 8, agent.indexOf(" ")) == "4.0" && agent.indexOf(")") + 1 == agent.length - 1) {32 browser = agent.substring(agent.indexOf("(") + 1, agent.indexOf(")")).split("; ")[agent.substring(agent.indexOf("(") + 1, agent.indexOf(")")).split("; ").length - 1];33 } else if (agent.substring(agent.indexOf("Mozilla/") + 8, agent.indexOf(" ")) == "4.0" && agent.indexOf(")") + 1 != agent.length - 1) {34 if (agent.substring(agent.indexOf(") ") + 2).indexOf("/") != -1) browser = agent.substring(agent.indexOf(") ") + 2, agent.indexOf(") ") + 2 + agent.substring(agent.indexOf(") ") + 2).indexOf("/"));35 if (agent.substring(agent.indexOf(") ") + 2).indexOf("/") == -1) browser = agent.substring(agent.indexOf(") ") + 2, agent.indexOf(") ") + 2 + agent.substring(agent.indexOf(") ") + 2).indexOf(" "));36 // browserVersion = agent.substring(agent.indexOf(browser)+browser.length+1, agent.indexOf(browser)+browser.length+1+agent.substring(agent.indexOf(browser)+browser.length+1).indexOf(" "));37 } else if (agent.substring(0, 6) == "Opera/") {38 browser = "Opera";39 // browserVersion = agent.substring(agent.indexOf(browser)+browser.length+1, agent.indexOf(browser)+browser.length+1+agent.substring(agent.indexOf(browser)+browser.length+1).indexOf(" "));40 if (agent.substring(agent.indexOf("(") + 1).indexOf(";") != -1) os = agent.substring(agent.indexOf("(") + 1, agent.indexOf("(") + 1 + agent.substring(agent.indexOf("(") + 1).indexOf(";"));41 if (agent.substring(agent.indexOf("(") + 1).indexOf(";") == -1) os = agent.substring(agent.indexOf("(") + 1, agent.indexOf("(") + 1 + agent.substring(agent.indexOf("(") + 1).indexOf(")"));42 } else if (agent.substring(0, agent.indexOf("/")) != "Mozilla" && agent.substring(0, agent.indexOf("/")) != "Opera") {43 browser = agent.substring(0, agent.indexOf("/"));44 // browserVersion = agent.substring(agent.indexOf(browser)+browser.length+1, agent.indexOf(browser)+browser.length+1+agent.substring(agent.indexOf(browser)+browser.length+1).indexOf(" "));45 } else {46 browser = agent;47 }
...
Using AI Code Generation
1const fc = require('fast-check');2const {indexOf} = require('fast-check-monorepo');3fc.assert(4 fc.property(fc.array(fc.integer()), fc.integer(), (arr, value) => {5 const result = indexOf(arr, value);6 return result === -1 || arr[result] === value;7 })8);9const fc = require('fast-check');10const {indexOf} = require('fast-check-monorepo');11fc.assert(12 fc.property(fc.array(fc.integer()), fc.integer(), (arr, value) => {13 const result = indexOf(arr, value);14 return result === -1 || arr[result] === value;15 })16);17const fc = require('fast-check');18const {indexOf} = require('fast-check-monorepo');19fc.assert(20 fc.property(fc.array(fc.integer()), fc.integer(), (arr, value) => {21 const result = indexOf(arr, value);22 return result === -1 || arr[result] === value;23 })24);25const fc = require('fast-check');26const {indexOf} = require('fast-check-monorepo');27fc.assert(28 fc.property(fc.array(fc.integer()), fc.integer(), (arr, value) => {29 const result = indexOf(arr, value);30 return result === -1 || arr[result] === value;31 })32);33const fc = require('fast-check');34const {indexOf} = require('fast-check-monorepo');35fc.assert(36 fc.property(fc.array(fc.integer()), fc.integer(), (arr, value) => {37 const result = indexOf(arr, value);38 return result === -1 || arr[result] === value;39 })40);41const fc = require('fast-check');42const {indexOf} = require('fast-check-monorepo');43fc.assert(44 fc.property(fc.array(fc.integer()), fc.integer(), (arr, value) => {45 const result = indexOf(arr, value);
Using AI Code Generation
1const fc = require('fast-check');2const isSubsequenceOf = (s1, s2) => {3 let i = 0;4 for (let j = 0; i < s1.length && j < s2.length; ++j) {5 if (s1[i] === s2[j]) {6 ++i;7 }8 }9 return i === s1.length;10};11const subsequenceOf = (s1, s2) => {12 const index = s2.indexOf(s1);13 return index >= 0 && index + s1.length <= s2.length;14};15const isSubsequenceOfProperty = (s1, s2) => {16 return isSubsequenceOf(s1, s2) === subsequenceOf(s1, s2);17};18fc.assert(19 fc.property(fc.string(), fc.string(), isSubsequenceOfProperty),20 { verbose: true }21);22const fc = require('fast-check');23const isSubsequenceOf = (s1, s2) => {24 let i = 0;25 for (let j = 0; i < s1.length && j < s2.length; ++j) {26 if (s1[i] === s2[j]) {27 ++i;28 }29 }30 return i === s1.length;31};32const subsequenceOf = (s1, s2) => {33 const index = s2.indexOf(s1);34 return index >= 0 && index + s1.length <= s2.length;35};36const isSubsequenceOfProperty = (s1, s2) => {37 return isSubsequenceOf(s1, s2) === subsequenceOf(s1, s2);38};39fc.assert(40 fc.property(fc.string(), fc.string(), isSubsequenceOfProperty),41 { verbose: true }42);43const fc = require('fast-check');44const isSubsequenceOf = (s1, s2) => {45 let i = 0;46 for (let j = 0; i < s1.length && j < s2.length; ++j) {47 if (s1[i] === s2[j]) {48 ++i;49 }50 }
Using AI Code Generation
1console.log(fastCheck.indexOf('fast-check', 'fast-check'));2console.log(fastCheck.indexOf('fast-check', 'fast-check', 1));3console.log(fastCheck.indexOf('fast-check', 'fast-check', 2));4console.log(fastCheck.indexOf('fast-check', 'fast-check', 3));5console.log(fastCheck.indexOf('fast-check', 'fast-check', 4));6console.log(fastCheck.indexOf('fast-check', 'fast-check', 5));7console.log(fastCheck.indexOf('fast-check', 'fast-check', 6));8console.log(fastCheck.indexOf('fast-check', 'fast-check', 7));9console.log(fastCheck.indexOf('fast-check', 'fast-check', 8));10console.log(fastCheck.indexOf('fast-check', 'fast-check', 9));11console.log(fastCheck.indexOf('fast-check', 'fast-check'));12console.log(fastCheck.indexOf('fast-check', 'fast-check', 1));13console.log(fastCheck.indexOf('fast-check', 'fast-check', 2));14console.log(fastCheck.indexOf('fast-check', 'fast-check', 3));15console.log(fastCheck.indexOf('fast-check', 'fast-check', 4));16console.log(fastCheck.indexOf('fast-check', 'fast-check', 5));17console.log(fastCheck.indexOf('fast-check', 'fast-check', 6));18console.log(fastCheck.indexOf('fast-check', 'fast-check', 7));19console.log(fastCheck.indexOf('fast-check', 'fast-check', 8));20console.log(fastCheck.indexOf('fast-check', 'fast-check', 9));21console.log(fastCheck.indexOf('fast-check', 'fast-check'));22console.log(fastCheck.indexOf('fast-check', 'fast-check', 1));23console.log(fastCheck.indexOf('fast-check', 'fast-check', 2));24console.log(fastCheck.indexOf('fast-check', 'fast-check', 3));25console.log(fastCheck.indexOf('fast-check', 'fast-check', 4));26console.log(fastCheck.indexOf('fast-check', 'fast-check', 5));27console.log(fastCheck.indexOf('fast-check', 'fast-check', 6));28console.log(fastCheck.indexOf('fast
Using AI Code Generation
1const fc = require('fast-check');2const { indexOf } = require('fast-check-monorepo');3const indexOfArb = fc.tuple(fc.string(), fc.char()).map(([str, c]) => {4 const index = indexOf(str, c);5 return [str, c, index];6});7fc.assert(8 fc.property(indexOfArb, ([str, c, index]) => {9 return index === -1 ? str.indexOf(c) === -1 : str[index] === c;10 })11);12const fc = require('fast-check');13const { indexOf } = require('fast-check-monorepo');14const indexOfArb = fc.tuple(fc.string(), fc.char()).map(([str, c]) => {15 const index = indexOf(str, c);16 return [str, c, index];17});18fc.assert(19 fc.property(indexOfArb, ([str, c, index]) => {20 return index === -1 ? str.indexOf(c) === -1 : str[index] === c;21 })22);23const fc = require('fast-check');24const { indexOf } = require('fast-check-monorepo');25const indexOfArb = fc.tuple(fc.string(), fc.char()).map(([str, c]) => {26 const index = indexOf(str, c);27 return [str, c, index];28});29fc.assert(30 fc.property(indexOfArb, ([str, c, index]) => {31 return index === -1 ? str.indexOf(c) === -1 : str[index] === c;32 })33);34const fc = require('fast-check');35const { indexOf } = require('fast-check-monorepo');36const indexOfArb = fc.tuple(fc.string(), fc.char()).map(([str, c]) => {37 const index = indexOf(str, c);38 return [str, c, index];39});40fc.assert(41 fc.property(indexOfArb, ([str, c, index]) => {42 return index === -1 ? str.indexOf(c) === -1 : str[index] === c;43 })44);
Using AI Code Generation
1const { indexOf } = require('fast-check');2const { check } = require('fast-check');3const { property } = require('fast-check');4check(5 property([1, 2, 3, 4], (arr) => {6 const idx = indexOf(arr, 2);7 return idx === 1;8 })9);10check(11 property([1, 2, 3, 4], (arr) => {12 const idx = indexOf(arr, 2);13 return idx === 1;14 })15);16check(17 property([1, 2, 3, 4], (arr) => {18 const idx = indexOf(arr, 2);19 return idx === 1;20 })21);22check(23 property([1, 2, 3, 4], (arr) => {24 const idx = indexOf(arr, 2);25 return idx === 1;26 })27);28check(29 property([1, 2, 3, 4], (arr) => {30 const idx = indexOf(arr, 2);31 return idx === 1;32 })33);34check(35 property([1, 2, 3, 4], (arr) => {36 const idx = indexOf(arr, 2);37 return idx === 1;38 })39);40check(41 property([1, 2, 3, 4], (arr) => {42 const idx = indexOf(arr, 2);43 return idx === 1;44 })45);46check(47 property([1, 2, 3, 4], (arr) => {48 const idx = indexOf(arr, 2);49 return idx === 1;50 })51);52check(53 property([1, 2, 3, 4], (arr) => {54 const idx = indexOf(arr, 2);55 return idx === 1;56 })57);58check(59 property([1, 2, 3, 4], (arr) => {60 const idx = indexOf(arr,
Using AI Code Generation
1const fc = require('fast-check');2const arrayArb = fc.array(fc.integer());3const array = arrayArb.generate(fc.random(1234)).value;4console.log(array);5const index = array.indexOf(1);6console.log(index);7const fc = require('fast-check');8const arrayArb = fc.array(fc.integer());9const array = arrayArb.generate(fc.random(1234)).value;10console.log(array);11const index = array.indexOf(1);12console.log(index);13import fc from 'fast-check';14import { render } from '@testing-library/react-native';15it('renders correctly', () => {16 fc.assert(17 fc.property(fc.string(), fc.string(), (a, b) => {18 const { getByText } = render(<App />);19 const element = getByText(`${a} ${b}`);20 expect(element).toBeDefined();21 })22 );23});24const fc = require('fast-check');25const { expect } = require('
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!