How to use generate method of Generator class

Best Mockingbird code snippet using Generator.generate

UrlGeneratorTest.php

Source:UrlGeneratorTest.php Github

copy

Full Screen

...18{19 public function testAbsoluteUrlWithPort80()20 {21 $routes = $this->getRoutes('test', new Route('/testing'));22 $url = $this->getGenerator($routes)->generate('test', [], UrlGeneratorInterface::ABSOLUTE_URL);23 $this->assertEquals('http://localhost/app.php/testing', $url);24 }25 public function testAbsoluteSecureUrlWithPort443()26 {27 $routes = $this->getRoutes('test', new Route('/testing'));28 $url = $this->getGenerator($routes, ['scheme' => 'https'])->generate('test', [], UrlGeneratorInterface::ABSOLUTE_URL);29 $this->assertEquals('https://localhost/app.php/testing', $url);30 }31 public function testAbsoluteUrlWithNonStandardPort()32 {33 $routes = $this->getRoutes('test', new Route('/testing'));34 $url = $this->getGenerator($routes, ['httpPort' => 8080])->generate('test', [], UrlGeneratorInterface::ABSOLUTE_URL);35 $this->assertEquals('http://localhost:8080/app.php/testing', $url);36 }37 public function testAbsoluteSecureUrlWithNonStandardPort()38 {39 $routes = $this->getRoutes('test', new Route('/testing'));40 $url = $this->getGenerator($routes, ['httpsPort' => 8080, 'scheme' => 'https'])->generate('test', [], UrlGeneratorInterface::ABSOLUTE_URL);41 $this->assertEquals('https://localhost:8080/app.php/testing', $url);42 }43 public function testRelativeUrlWithoutParameters()44 {45 $routes = $this->getRoutes('test', new Route('/testing'));46 $url = $this->getGenerator($routes)->generate('test', [], UrlGeneratorInterface::ABSOLUTE_PATH);47 $this->assertEquals('/app.php/testing', $url);48 }49 public function testRelativeUrlWithParameter()50 {51 $routes = $this->getRoutes('test', new Route('/testing/{foo}'));52 $url = $this->getGenerator($routes)->generate('test', ['foo' => 'bar'], UrlGeneratorInterface::ABSOLUTE_PATH);53 $this->assertEquals('/app.php/testing/bar', $url);54 }55 public function testRelativeUrlWithNullParameter()56 {57 $routes = $this->getRoutes('test', new Route('/testing.{format}', ['format' => null]));58 $url = $this->getGenerator($routes)->generate('test', [], UrlGeneratorInterface::ABSOLUTE_PATH);59 $this->assertEquals('/app.php/testing', $url);60 }61 public function testRelativeUrlWithNullParameterButNotOptional()62 {63 $this->expectException('Symfony\Component\Routing\Exception\InvalidParameterException');64 $routes = $this->getRoutes('test', new Route('/testing/{foo}/bar', ['foo' => null]));65 // This must raise an exception because the default requirement for "foo" is "[^/]+" which is not met with these params.66 // Generating path "/testing//bar" would be wrong as matching this route would fail.67 $this->getGenerator($routes)->generate('test', [], UrlGeneratorInterface::ABSOLUTE_PATH);68 }69 public function testRelativeUrlWithOptionalZeroParameter()70 {71 $routes = $this->getRoutes('test', new Route('/testing/{page}'));72 $url = $this->getGenerator($routes)->generate('test', ['page' => 0], UrlGeneratorInterface::ABSOLUTE_PATH);73 $this->assertEquals('/app.php/testing/0', $url);74 }75 public function testNotPassedOptionalParameterInBetween()76 {77 $routes = $this->getRoutes('test', new Route('/{slug}/{page}', ['slug' => 'index', 'page' => 0]));78 $this->assertSame('/app.php/index/1', $this->getGenerator($routes)->generate('test', ['page' => 1]));79 $this->assertSame('/app.php/', $this->getGenerator($routes)->generate('test'));80 }81 public function testRelativeUrlWithExtraParameters()82 {83 $routes = $this->getRoutes('test', new Route('/testing'));84 $url = $this->getGenerator($routes)->generate('test', ['foo' => 'bar'], UrlGeneratorInterface::ABSOLUTE_PATH);85 $this->assertEquals('/app.php/testing?foo=bar', $url);86 }87 public function testAbsoluteUrlWithExtraParameters()88 {89 $routes = $this->getRoutes('test', new Route('/testing'));90 $url = $this->getGenerator($routes)->generate('test', ['foo' => 'bar'], UrlGeneratorInterface::ABSOLUTE_URL);91 $this->assertEquals('http://localhost/app.php/testing?foo=bar', $url);92 }93 public function testUrlWithNullExtraParameters()94 {95 $routes = $this->getRoutes('test', new Route('/testing'));96 $url = $this->getGenerator($routes)->generate('test', ['foo' => null], UrlGeneratorInterface::ABSOLUTE_URL);97 $this->assertEquals('http://localhost/app.php/testing', $url);98 }99 public function testUrlWithExtraParametersFromGlobals()100 {101 $routes = $this->getRoutes('test', new Route('/testing'));102 $generator = $this->getGenerator($routes);103 $context = new RequestContext('/app.php');104 $context->setParameter('bar', 'bar');105 $generator->setContext($context);106 $url = $generator->generate('test', ['foo' => 'bar']);107 $this->assertEquals('/app.php/testing?foo=bar', $url);108 }109 public function testUrlWithGlobalParameter()110 {111 $routes = $this->getRoutes('test', new Route('/testing/{foo}'));112 $generator = $this->getGenerator($routes);113 $context = new RequestContext('/app.php');114 $context->setParameter('foo', 'bar');115 $generator->setContext($context);116 $url = $generator->generate('test', []);117 $this->assertEquals('/app.php/testing/bar', $url);118 }119 public function testGlobalParameterHasHigherPriorityThanDefault()120 {121 $routes = $this->getRoutes('test', new Route('/{_locale}', ['_locale' => 'en']));122 $generator = $this->getGenerator($routes);123 $context = new RequestContext('/app.php');124 $context->setParameter('_locale', 'de');125 $generator->setContext($context);126 $url = $generator->generate('test', []);127 $this->assertSame('/app.php/de', $url);128 }129 public function testGenerateWithDefaultLocale()130 {131 $routes = new RouteCollection();132 $route = new Route('');133 $name = 'test';134 foreach (['hr' => '/foo', 'en' => '/bar'] as $locale => $path) {135 $localizedRoute = clone $route;136 $localizedRoute->setDefault('_locale', $locale);137 $localizedRoute->setDefault('_canonical_route', $name);138 $localizedRoute->setPath($path);139 $routes->add($name.'.'.$locale, $localizedRoute);140 }141 $generator = $this->getGenerator($routes, [], null, 'hr');142 $this->assertSame(143 'http://localhost/app.php/foo',144 $generator->generate($name, [], UrlGeneratorInterface::ABSOLUTE_URL)145 );146 }147 public function testGenerateWithOverriddenParameterLocale()148 {149 $routes = new RouteCollection();150 $route = new Route('');151 $name = 'test';152 foreach (['hr' => '/foo', 'en' => '/bar'] as $locale => $path) {153 $localizedRoute = clone $route;154 $localizedRoute->setDefault('_locale', $locale);155 $localizedRoute->setDefault('_canonical_route', $name);156 $localizedRoute->setPath($path);157 $routes->add($name.'.'.$locale, $localizedRoute);158 }159 $generator = $this->getGenerator($routes, [], null, 'hr');160 $this->assertSame(161 'http://localhost/app.php/bar',162 $generator->generate($name, ['_locale' => 'en'], UrlGeneratorInterface::ABSOLUTE_URL)163 );164 }165 public function testGenerateWithOverriddenParameterLocaleFromRequestContext()166 {167 $routes = new RouteCollection();168 $route = new Route('');169 $name = 'test';170 foreach (['hr' => '/foo', 'en' => '/bar'] as $locale => $path) {171 $localizedRoute = clone $route;172 $localizedRoute->setDefault('_locale', $locale);173 $localizedRoute->setDefault('_canonical_route', $name);174 $localizedRoute->setPath($path);175 $routes->add($name.'.'.$locale, $localizedRoute);176 }177 $generator = $this->getGenerator($routes, [], null, 'hr');178 $context = new RequestContext('/app.php');179 $context->setParameter('_locale', 'en');180 $generator->setContext($context);181 $this->assertSame(182 'http://localhost/app.php/bar',183 $generator->generate($name, [], UrlGeneratorInterface::ABSOLUTE_URL)184 );185 }186 public function testGenerateWithoutRoutes()187 {188 $this->expectException('Symfony\Component\Routing\Exception\RouteNotFoundException');189 $routes = $this->getRoutes('foo', new Route('/testing/{foo}'));190 $this->getGenerator($routes)->generate('test', [], UrlGeneratorInterface::ABSOLUTE_URL);191 }192 public function testGenerateWithInvalidLocale()193 {194 $this->expectException('Symfony\Component\Routing\Exception\RouteNotFoundException');195 $routes = new RouteCollection();196 $route = new Route('');197 $name = 'test';198 foreach (['hr' => '/foo', 'en' => '/bar'] as $locale => $path) {199 $localizedRoute = clone $route;200 $localizedRoute->setDefault('_locale', $locale);201 $localizedRoute->setDefault('_canonical_route', $name);202 $localizedRoute->setPath($path);203 $routes->add($name.'.'.$locale, $localizedRoute);204 }205 $generator = $this->getGenerator($routes, [], null, 'fr');206 $generator->generate($name);207 }208 public function testGenerateForRouteWithoutMandatoryParameter()209 {210 $this->expectException('Symfony\Component\Routing\Exception\MissingMandatoryParametersException');211 $routes = $this->getRoutes('test', new Route('/testing/{foo}'));212 $this->getGenerator($routes)->generate('test', [], UrlGeneratorInterface::ABSOLUTE_URL);213 }214 public function testGenerateForRouteWithInvalidOptionalParameter()215 {216 $this->expectException('Symfony\Component\Routing\Exception\InvalidParameterException');217 $routes = $this->getRoutes('test', new Route('/testing/{foo}', ['foo' => '1'], ['foo' => 'd+']));218 $this->getGenerator($routes)->generate('test', ['foo' => 'bar'], UrlGeneratorInterface::ABSOLUTE_URL);219 }220 public function testGenerateForRouteWithInvalidParameter()221 {222 $this->expectException('Symfony\Component\Routing\Exception\InvalidParameterException');223 $routes = $this->getRoutes('test', new Route('/testing/{foo}', [], ['foo' => '1|2']));224 $this->getGenerator($routes)->generate('test', ['foo' => '0'], UrlGeneratorInterface::ABSOLUTE_URL);225 }226 public function testGenerateForRouteWithInvalidOptionalParameterNonStrict()227 {228 $routes = $this->getRoutes('test', new Route('/testing/{foo}', ['foo' => '1'], ['foo' => 'd+']));229 $generator = $this->getGenerator($routes);230 $generator->setStrictRequirements(false);231 $this->assertSame('', $generator->generate('test', ['foo' => 'bar'], UrlGeneratorInterface::ABSOLUTE_URL));232 }233 public function testGenerateForRouteWithInvalidOptionalParameterNonStrictWithLogger()234 {235 $routes = $this->getRoutes('test', new Route('/testing/{foo}', ['foo' => '1'], ['foo' => 'd+']));236 $logger = $this->getMockBuilder('Psr\Log\LoggerInterface')->getMock();237 $logger->expects($this->once())238 ->method('error');239 $generator = $this->getGenerator($routes, [], $logger);240 $generator->setStrictRequirements(false);241 $this->assertSame('', $generator->generate('test', ['foo' => 'bar'], UrlGeneratorInterface::ABSOLUTE_URL));242 }243 public function testGenerateForRouteWithInvalidParameterButDisabledRequirementsCheck()244 {245 $routes = $this->getRoutes('test', new Route('/testing/{foo}', ['foo' => '1'], ['foo' => 'd+']));246 $generator = $this->getGenerator($routes);247 $generator->setStrictRequirements(null);248 $this->assertSame('/app.php/testing/bar', $generator->generate('test', ['foo' => 'bar']));249 }250 public function testGenerateForRouteWithInvalidMandatoryParameter()251 {252 $this->expectException('Symfony\Component\Routing\Exception\InvalidParameterException');253 $routes = $this->getRoutes('test', new Route('/testing/{foo}', [], ['foo' => 'd+']));254 $this->getGenerator($routes)->generate('test', ['foo' => 'bar'], UrlGeneratorInterface::ABSOLUTE_URL);255 }256 public function testGenerateForRouteWithInvalidUtf8Parameter()257 {258 $this->expectException('Symfony\Component\Routing\Exception\InvalidParameterException');259 $routes = $this->getRoutes('test', new Route('/testing/{foo}', [], ['foo' => '\pL+'], ['utf8' => true]));260 $this->getGenerator($routes)->generate('test', ['foo' => 'abc123'], UrlGeneratorInterface::ABSOLUTE_URL);261 }262 public function testRequiredParamAndEmptyPassed()263 {264 $this->expectException('Symfony\Component\Routing\Exception\InvalidParameterException');265 $routes = $this->getRoutes('test', new Route('/{slug}', [], ['slug' => '.+']));266 $this->getGenerator($routes)->generate('test', ['slug' => '']);267 }268 public function testSchemeRequirementDoesNothingIfSameCurrentScheme()269 {270 $routes = $this->getRoutes('test', new Route('/', [], [], [], '', ['http']));271 $this->assertEquals('/app.php/', $this->getGenerator($routes)->generate('test'));272 $routes = $this->getRoutes('test', new Route('/', [], [], [], '', ['https']));273 $this->assertEquals('/app.php/', $this->getGenerator($routes, ['scheme' => 'https'])->generate('test'));274 }275 public function testSchemeRequirementForcesAbsoluteUrl()276 {277 $routes = $this->getRoutes('test', new Route('/', [], [], [], '', ['https']));278 $this->assertEquals('https://localhost/app.php/', $this->getGenerator($routes)->generate('test'));279 $routes = $this->getRoutes('test', new Route('/', [], [], [], '', ['http']));280 $this->assertEquals('http://localhost/app.php/', $this->getGenerator($routes, ['scheme' => 'https'])->generate('test'));281 }282 public function testSchemeRequirementCreatesUrlForFirstRequiredScheme()283 {284 $routes = $this->getRoutes('test', new Route('/', [], [], [], '', ['Ftp', 'https']));285 $this->assertEquals('ftp://localhost/app.php/', $this->getGenerator($routes)->generate('test'));286 }287 public function testPathWithTwoStartingSlashes()288 {289 $routes = $this->getRoutes('test', new Route('//path-and-not-domain'));290 // this must not generate '//path-and-not-domain' because that would be a network path291 $this->assertSame('/path-and-not-domain', $this->getGenerator($routes, ['BaseUrl' => ''])->generate('test'));292 }293 public function testNoTrailingSlashForMultipleOptionalParameters()294 {295 $routes = $this->getRoutes('test', new Route('/category/{slug1}/{slug2}/{slug3}', ['slug2' => null, 'slug3' => null]));296 $this->assertEquals('/app.php/category/foo', $this->getGenerator($routes)->generate('test', ['slug1' => 'foo']));297 }298 public function testWithAnIntegerAsADefaultValue()299 {300 $routes = $this->getRoutes('test', new Route('/{default}', ['default' => 0]));301 $this->assertEquals('/app.php/foo', $this->getGenerator($routes)->generate('test', ['default' => 'foo']));302 }303 public function testNullForOptionalParameterIsIgnored()304 {305 $routes = $this->getRoutes('test', new Route('/test/{default}', ['default' => 0]));306 $this->assertEquals('/app.php/test', $this->getGenerator($routes)->generate('test', ['default' => null]));307 }308 public function testQueryParamSameAsDefault()309 {310 $routes = $this->getRoutes('test', new Route('/test', ['page' => 1]));311 $this->assertSame('/app.php/test?page=2', $this->getGenerator($routes)->generate('test', ['page' => 2]));312 $this->assertSame('/app.php/test', $this->getGenerator($routes)->generate('test', ['page' => 1]));313 $this->assertSame('/app.php/test', $this->getGenerator($routes)->generate('test', ['page' => '1']));314 $this->assertSame('/app.php/test', $this->getGenerator($routes)->generate('test'));315 }316 public function testArrayQueryParamSameAsDefault()317 {318 $routes = $this->getRoutes('test', new Route('/test', ['array' => ['foo', 'bar']]));319 $this->assertSame('/app.php/test?array%5B0%5D=bar&array%5B1%5D=foo', $this->getGenerator($routes)->generate('test', ['array' => ['bar', 'foo']]));320 $this->assertSame('/app.php/test?array%5Ba%5D=foo&array%5Bb%5D=bar', $this->getGenerator($routes)->generate('test', ['array' => ['a' => 'foo', 'b' => 'bar']]));321 $this->assertSame('/app.php/test', $this->getGenerator($routes)->generate('test', ['array' => ['foo', 'bar']]));322 $this->assertSame('/app.php/test', $this->getGenerator($routes)->generate('test', ['array' => [1 => 'bar', 0 => 'foo']]));323 $this->assertSame('/app.php/test', $this->getGenerator($routes)->generate('test'));324 }325 public function testGenerateWithSpecialRouteName()326 {327 $routes = $this->getRoutes('$péß^a|', new Route('/bar'));328 $this->assertSame('/app.php/bar', $this->getGenerator($routes)->generate('$péß^a|'));329 }330 public function testUrlEncoding()331 {332 $expectedPath = '/app.php/@:%5B%5D/%28%29*%27%22%20+,;-._~%26%24%3C%3E|%7B%7D%25%5C%5E%60!%3Ffoo=bar%23id'333 .'/@:%5B%5D/%28%29*%27%22%20+,;-._~%26%24%3C%3E|%7B%7D%25%5C%5E%60!%3Ffoo=bar%23id'334 .'?query=@:%5B%5D/%28%29*%27%22%20%2B,;-._~%26%24%3C%3E%7C%7B%7D%25%5C%5E%60!?foo%3Dbar%23id';335 // This tests the encoding of reserved characters that are used for delimiting of URI components (defined in RFC 3986)336 // and other special ASCII chars. These chars are tested as static text path, variable path and query param.337 $chars = '@:[]/()*\'" +,;-._~&$<>|{}%\\^`!?foo=bar#id';338 $routes = $this->getRoutes('test', new Route("/$chars/{varpath}", [], ['varpath' => '.+']));339 $this->assertSame($expectedPath, $this->getGenerator($routes)->generate('test', [340 'varpath' => $chars,341 'query' => $chars,342 ]));343 }344 public function testEncodingOfRelativePathSegments()345 {346 $routes = $this->getRoutes('test', new Route('/dir/../dir/..'));347 $this->assertSame('/app.php/dir/%2E%2E/dir/%2E%2E', $this->getGenerator($routes)->generate('test'));348 $routes = $this->getRoutes('test', new Route('/dir/./dir/.'));349 $this->assertSame('/app.php/dir/%2E/dir/%2E', $this->getGenerator($routes)->generate('test'));350 $routes = $this->getRoutes('test', new Route('/a./.a/a../..a/...'));351 $this->assertSame('/app.php/a./.a/a../..a/...', $this->getGenerator($routes)->generate('test'));352 }353 public function testAdjacentVariables()354 {355 $routes = $this->getRoutes('test', new Route('/{x}{y}{z}.{_format}', ['z' => 'default-z', '_format' => 'html'], ['y' => '\d+']));356 $generator = $this->getGenerator($routes);357 $this->assertSame('/app.php/foo123', $generator->generate('test', ['x' => 'foo', 'y' => '123']));358 $this->assertSame('/app.php/foo123bar.xml', $generator->generate('test', ['x' => 'foo', 'y' => '123', 'z' => 'bar', '_format' => 'xml']));359 // The default requirement for 'x' should not allow the separator '.' in this case because it would otherwise match everything360 // and following optional variables like _format could never match.361 $this->expectException('Symfony\Component\Routing\Exception\InvalidParameterException');362 $generator->generate('test', ['x' => 'do.t', 'y' => '123', 'z' => 'bar', '_format' => 'xml']);363 }364 public function testOptionalVariableWithNoRealSeparator()365 {366 $routes = $this->getRoutes('test', new Route('/get{what}', ['what' => 'All']));367 $generator = $this->getGenerator($routes);368 $this->assertSame('/app.php/get', $generator->generate('test'));369 $this->assertSame('/app.php/getSites', $generator->generate('test', ['what' => 'Sites']));370 }371 public function testRequiredVariableWithNoRealSeparator()372 {373 $routes = $this->getRoutes('test', new Route('/get{what}Suffix'));374 $generator = $this->getGenerator($routes);375 $this->assertSame('/app.php/getSitesSuffix', $generator->generate('test', ['what' => 'Sites']));376 }377 public function testDefaultRequirementOfVariable()378 {379 $routes = $this->getRoutes('test', new Route('/{page}.{_format}'));380 $generator = $this->getGenerator($routes);381 $this->assertSame('/app.php/index.mobile.html', $generator->generate('test', ['page' => 'index', '_format' => 'mobile.html']));382 }383 public function testImportantVariable()384 {385 $routes = $this->getRoutes('test', (new Route('/{page}.{!_format}'))->addDefaults(['_format' => 'mobile.html']));386 $generator = $this->getGenerator($routes);387 $this->assertSame('/app.php/index.xml', $generator->generate('test', ['page' => 'index', '_format' => 'xml']));388 $this->assertSame('/app.php/index.mobile.html', $generator->generate('test', ['page' => 'index', '_format' => 'mobile.html']));389 $this->assertSame('/app.php/index.mobile.html', $generator->generate('test', ['page' => 'index']));390 }391 public function testImportantVariableWithNoDefault()392 {393 $this->expectException('Symfony\Component\Routing\Exception\MissingMandatoryParametersException');394 $routes = $this->getRoutes('test', new Route('/{page}.{!_format}'));395 $generator = $this->getGenerator($routes);396 $generator->generate('test', ['page' => 'index']);397 }398 public function testDefaultRequirementOfVariableDisallowsSlash()399 {400 $this->expectException('Symfony\Component\Routing\Exception\InvalidParameterException');401 $routes = $this->getRoutes('test', new Route('/{page}.{_format}'));402 $this->getGenerator($routes)->generate('test', ['page' => 'index', '_format' => 'sl/ash']);403 }404 public function testDefaultRequirementOfVariableDisallowsNextSeparator()405 {406 $this->expectException('Symfony\Component\Routing\Exception\InvalidParameterException');407 $routes = $this->getRoutes('test', new Route('/{page}.{_format}'));408 $this->getGenerator($routes)->generate('test', ['page' => 'do.t', '_format' => 'html']);409 }410 public function testWithHostDifferentFromContext()411 {412 $routes = $this->getRoutes('test', new Route('/{name}', [], [], [], '{locale}.example.com'));413 $this->assertEquals('//fr.example.com/app.php/Fabien', $this->getGenerator($routes)->generate('test', ['name' => 'Fabien', 'locale' => 'fr']));414 }415 public function testWithHostSameAsContext()416 {417 $routes = $this->getRoutes('test', new Route('/{name}', [], [], [], '{locale}.example.com'));418 $this->assertEquals('/app.php/Fabien', $this->getGenerator($routes, ['host' => 'fr.example.com'])->generate('test', ['name' => 'Fabien', 'locale' => 'fr']));419 }420 public function testWithHostSameAsContextAndAbsolute()421 {422 $routes = $this->getRoutes('test', new Route('/{name}', [], [], [], '{locale}.example.com'));423 $this->assertEquals('http://fr.example.com/app.php/Fabien', $this->getGenerator($routes, ['host' => 'fr.example.com'])->generate('test', ['name' => 'Fabien', 'locale' => 'fr'], UrlGeneratorInterface::ABSOLUTE_URL));424 }425 public function testUrlWithInvalidParameterInHost()426 {427 $this->expectException('Symfony\Component\Routing\Exception\InvalidParameterException');428 $routes = $this->getRoutes('test', new Route('/', [], ['foo' => 'bar'], [], '{foo}.example.com'));429 $this->getGenerator($routes)->generate('test', ['foo' => 'baz'], UrlGeneratorInterface::ABSOLUTE_PATH);430 }431 public function testUrlWithInvalidParameterInHostWhenParamHasADefaultValue()432 {433 $this->expectException('Symfony\Component\Routing\Exception\InvalidParameterException');434 $routes = $this->getRoutes('test', new Route('/', ['foo' => 'bar'], ['foo' => 'bar'], [], '{foo}.example.com'));435 $this->getGenerator($routes)->generate('test', ['foo' => 'baz'], UrlGeneratorInterface::ABSOLUTE_PATH);436 }437 public function testUrlWithInvalidParameterEqualsDefaultValueInHost()438 {439 $this->expectException('Symfony\Component\Routing\Exception\InvalidParameterException');440 $routes = $this->getRoutes('test', new Route('/', ['foo' => 'baz'], ['foo' => 'bar'], [], '{foo}.example.com'));441 $this->getGenerator($routes)->generate('test', ['foo' => 'baz'], UrlGeneratorInterface::ABSOLUTE_PATH);442 }443 public function testUrlWithInvalidParameterInHostInNonStrictMode()444 {445 $routes = $this->getRoutes('test', new Route('/', [], ['foo' => 'bar'], [], '{foo}.example.com'));446 $generator = $this->getGenerator($routes);447 $generator->setStrictRequirements(false);448 $this->assertSame('', $generator->generate('test', ['foo' => 'baz'], UrlGeneratorInterface::ABSOLUTE_PATH));449 }450 public function testHostIsCaseInsensitive()451 {452 $routes = $this->getRoutes('test', new Route('/', [], ['locale' => 'en|de|fr'], [], '{locale}.FooBar.com'));453 $generator = $this->getGenerator($routes);454 $this->assertSame('//EN.FooBar.com/app.php/', $generator->generate('test', ['locale' => 'EN'], UrlGeneratorInterface::NETWORK_PATH));455 }456 public function testDefaultHostIsUsedWhenContextHostIsEmpty()457 {458 $routes = $this->getRoutes('test', new Route('/path', ['domain' => 'my.fallback.host'], ['domain' => '.+'], [], '{domain}'));459 $generator = $this->getGenerator($routes);460 $generator->getContext()->setHost('');461 $this->assertSame('http://my.fallback.host/app.php/path', $generator->generate('test', [], UrlGeneratorInterface::ABSOLUTE_URL));462 }463 public function testDefaultHostIsUsedWhenContextHostIsEmptyAndPathReferenceType()464 {465 $routes = $this->getRoutes('test', new Route('/path', ['domain' => 'my.fallback.host'], ['domain' => '.+'], [], '{domain}'));466 $generator = $this->getGenerator($routes);467 $generator->getContext()->setHost('');468 $this->assertSame('//my.fallback.host/app.php/path', $generator->generate('test', [], UrlGeneratorInterface::ABSOLUTE_PATH));469 }470 public function testAbsoluteUrlFallbackToPathIfHostIsEmptyAndSchemeIsHttp()471 {472 $routes = $this->getRoutes('test', new Route('/route'));473 $generator = $this->getGenerator($routes);474 $generator->getContext()->setHost('');475 $generator->getContext()->setScheme('https');476 $this->assertSame('/app.php/route', $generator->generate('test', [], UrlGeneratorInterface::ABSOLUTE_URL));477 }478 public function testAbsoluteUrlFallbackToNetworkIfSchemeIsEmptyAndHostIsNot()479 {480 $routes = $this->getRoutes('test', new Route('/path'));481 $generator = $this->getGenerator($routes);482 $generator->getContext()->setHost('example.com');483 $generator->getContext()->setScheme('');484 $this->assertSame('//example.com/app.php/path', $generator->generate('test', [], UrlGeneratorInterface::ABSOLUTE_URL));485 }486 public function testAbsoluteUrlFallbackToPathIfSchemeAndHostAreEmpty()487 {488 $routes = $this->getRoutes('test', new Route('/path'));489 $generator = $this->getGenerator($routes);490 $generator->getContext()->setHost('');491 $generator->getContext()->setScheme('');492 $this->assertSame('/app.php/path', $generator->generate('test', [], UrlGeneratorInterface::ABSOLUTE_URL));493 }494 public function testAbsoluteUrlWithNonHttpSchemeAndEmptyHost()495 {496 $routes = $this->getRoutes('test', new Route('/path', [], [], [], '', ['file']));497 $generator = $this->getGenerator($routes);498 $generator->getContext()->setBaseUrl('');499 $generator->getContext()->setHost('');500 $this->assertSame('file:///path', $generator->generate('test', [], UrlGeneratorInterface::ABSOLUTE_URL));501 }502 public function testGenerateNetworkPath()503 {504 $routes = $this->getRoutes('test', new Route('/{name}', [], [], [], '{locale}.example.com', ['http']));505 $this->assertSame('//fr.example.com/app.php/Fabien', $this->getGenerator($routes)->generate('test',506 ['name' => 'Fabien', 'locale' => 'fr'], UrlGeneratorInterface::NETWORK_PATH), 'network path with different host'507 );508 $this->assertSame('//fr.example.com/app.php/Fabien?query=string', $this->getGenerator($routes, ['host' => 'fr.example.com'])->generate('test',509 ['name' => 'Fabien', 'locale' => 'fr', 'query' => 'string'], UrlGeneratorInterface::NETWORK_PATH), 'network path although host same as context'510 );511 $this->assertSame('http://fr.example.com/app.php/Fabien', $this->getGenerator($routes, ['scheme' => 'https'])->generate('test',512 ['name' => 'Fabien', 'locale' => 'fr'], UrlGeneratorInterface::NETWORK_PATH), 'absolute URL because scheme requirement does not match context'513 );514 $this->assertSame('http://fr.example.com/app.php/Fabien', $this->getGenerator($routes)->generate('test',515 ['name' => 'Fabien', 'locale' => 'fr'], UrlGeneratorInterface::ABSOLUTE_URL), 'absolute URL with same scheme because it is requested'516 );517 }518 public function testGenerateRelativePath()519 {520 $routes = new RouteCollection();521 $routes->add('article', new Route('/{author}/{article}/'));522 $routes->add('comments', new Route('/{author}/{article}/comments'));523 $routes->add('host', new Route('/{article}', [], [], [], '{author}.example.com'));524 $routes->add('scheme', new Route('/{author}/blog', [], [], [], '', ['https']));525 $routes->add('unrelated', new Route('/about'));526 $generator = $this->getGenerator($routes, ['host' => 'example.com', 'pathInfo' => '/fabien/symfony-is-great/']);527 $this->assertSame('comments', $generator->generate('comments',528 ['author' => 'fabien', 'article' => 'symfony-is-great'], UrlGeneratorInterface::RELATIVE_PATH)529 );530 $this->assertSame('comments?page=2', $generator->generate('comments',531 ['author' => 'fabien', 'article' => 'symfony-is-great', 'page' => 2], UrlGeneratorInterface::RELATIVE_PATH)532 );533 $this->assertSame('../twig-is-great/', $generator->generate('article',534 ['author' => 'fabien', 'article' => 'twig-is-great'], UrlGeneratorInterface::RELATIVE_PATH)535 );536 $this->assertSame('../../bernhard/forms-are-great/', $generator->generate('article',537 ['author' => 'bernhard', 'article' => 'forms-are-great'], UrlGeneratorInterface::RELATIVE_PATH)538 );539 $this->assertSame('//bernhard.example.com/app.php/forms-are-great', $generator->generate('host',540 ['author' => 'bernhard', 'article' => 'forms-are-great'], UrlGeneratorInterface::RELATIVE_PATH)541 );542 $this->assertSame('https://example.com/app.php/bernhard/blog', $generator->generate('scheme',543 ['author' => 'bernhard'], UrlGeneratorInterface::RELATIVE_PATH)544 );545 $this->assertSame('../../about', $generator->generate('unrelated',546 [], UrlGeneratorInterface::RELATIVE_PATH)547 );548 }549 /**550 * @dataProvider provideRelativePaths551 */552 public function testGetRelativePath($sourcePath, $targetPath, $expectedPath)553 {554 $this->assertSame($expectedPath, UrlGenerator::getRelativePath($sourcePath, $targetPath));555 }556 public function provideRelativePaths()557 {558 return [559 [560 '/same/dir/',561 '/same/dir/',562 '',563 ],564 [565 '/same/file',566 '/same/file',567 '',568 ],569 [570 '/',571 '/file',572 'file',573 ],574 [575 '/',576 '/dir/file',577 'dir/file',578 ],579 [580 '/dir/file.html',581 '/dir/different-file.html',582 'different-file.html',583 ],584 [585 '/same/dir/extra-file',586 '/same/dir/',587 './',588 ],589 [590 '/parent/dir/',591 '/parent/',592 '../',593 ],594 [595 '/parent/dir/extra-file',596 '/parent/',597 '../',598 ],599 [600 '/a/b/',601 '/x/y/z/',602 '../../x/y/z/',603 ],604 [605 '/a/b/c/d/e',606 '/a/c/d',607 '../../../c/d',608 ],609 [610 '/a/b/c//',611 '/a/b/c/',612 '../',613 ],614 [615 '/a/b/c/',616 '/a/b/c//',617 './/',618 ],619 [620 '/root/a/b/c/',621 '/root/x/b/c/',622 '../../../x/b/c/',623 ],624 [625 '/a/b/c/d/',626 '/a',627 '../../../../a',628 ],629 [630 '/special-chars/sp%20ce/1€/mäh/e=mc²',631 '/special-chars/sp%20ce/1€/<µ>/e=mc²',632 '../<µ>/e=mc²',633 ],634 [635 'not-rooted',636 'dir/file',637 'dir/file',638 ],639 [640 '//dir/',641 '',642 '../../',643 ],644 [645 '/dir/',646 '/dir/file:with-colon',647 './file:with-colon',648 ],649 [650 '/dir/',651 '/dir/subdir/file:with-colon',652 'subdir/file:with-colon',653 ],654 [655 '/dir/',656 '/dir/:subdir/',657 './:subdir/',658 ],659 ];660 }661 public function testFragmentsCanBeAppendedToUrls()662 {663 $routes = $this->getRoutes('test', new Route('/testing'));664 $url = $this->getGenerator($routes)->generate('test', ['_fragment' => 'frag ment'], UrlGeneratorInterface::ABSOLUTE_PATH);665 $this->assertEquals('/app.php/testing#frag%20ment', $url);666 $url = $this->getGenerator($routes)->generate('test', ['_fragment' => '0'], UrlGeneratorInterface::ABSOLUTE_PATH);667 $this->assertEquals('/app.php/testing#0', $url);668 }669 public function testFragmentsDoNotEscapeValidCharacters()670 {671 $routes = $this->getRoutes('test', new Route('/testing'));672 $url = $this->getGenerator($routes)->generate('test', ['_fragment' => '?/'], UrlGeneratorInterface::ABSOLUTE_PATH);673 $this->assertEquals('/app.php/testing#?/', $url);674 }675 public function testFragmentsCanBeDefinedAsDefaults()676 {677 $routes = $this->getRoutes('test', new Route('/testing', ['_fragment' => 'fragment']));678 $url = $this->getGenerator($routes)->generate('test', [], UrlGeneratorInterface::ABSOLUTE_PATH);679 $this->assertEquals('/app.php/testing#fragment', $url);680 }681 /**682 * @dataProvider provideLookAroundRequirementsInPath683 */684 public function testLookRoundRequirementsInPath($expected, $path, $requirement)685 {686 $routes = $this->getRoutes('test', new Route($path, [], ['foo' => $requirement, 'baz' => '.+?']));687 $this->assertSame($expected, $this->getGenerator($routes)->generate('test', ['foo' => 'a/b', 'baz' => 'c/d/e']));688 }689 public function provideLookAroundRequirementsInPath()690 {691 yield ['/app.php/a/b/b%28ar/c/d/e', '/{foo}/b(ar/{baz}', '.+(?=/b\\(ar/)'];692 yield ['/app.php/a/b/bar/c/d/e', '/{foo}/bar/{baz}', '.+(?!$)'];693 yield ['/app.php/bar/a/b/bam/c/d/e', '/bar/{foo}/bam/{baz}', '(?<=/bar/).+'];694 yield ['/app.php/bar/a/b/bam/c/d/e', '/bar/{foo}/bam/{baz}', '(?<!^).+'];695 }696 protected function getGenerator(RouteCollection $routes, array $parameters = [], $logger = null, string $defaultLocale = null)697 {698 $context = new RequestContext('/app.php');699 foreach ($parameters as $key => $value) {700 $method = 'set'.$key;701 $context->$method($value);...

Full Screen

Full Screen

V8Profile.swift

Source:V8Profile.swift Github

copy

Full Screen

...26 b.eval("%VerifyType(%@)", with: [v])27}28fileprivate let MapTransitionsTemplate = ProgramTemplate("MapTransitionsTemplate", requiresPrefix: false) { b in29 // This template is meant to stress the v8 Map transition mechanisms.30 // Basically, it generates a bunch of CreateObject, LoadProperty, StoreProperty, FunctionDefinition,31 // and CallFunction operations operating on a small set of objects and property names.32 let propertyNames = ["a", "b", "c", "d", "e", "f", "g"]33 assert(Set(propertyNames).isDisjoint(with: b.fuzzer.environment.customMethodNames))34 // Use this as base object type. For one, this ensures that the initial map is stable.35 // Moreover, this guarantees that when querying for this type, we will receive one of36 // the objects we created and not e.g. a function (which is also an object).37 let objType = Type.object(withProperties: ["a"])38 // Signature of functions generated in this template39 let sig = [.plain(objType), .plain(objType)] => objType40 // Create property values: integers, doubles, and heap objects.41 // These should correspond to the supported property representations of the engine.42 let intVal = b.loadInt(42)43 let floatVal = b.loadFloat(13.37)44 let objVal = b.createObject(with: [:])45 let propertyValues = [intVal, floatVal, objVal]46 // Now create a bunch of objects to operate on.47 // Keep track of all objects created in this template so that they can be verified at the end.48 var objects = [objVal]49 for _ in 0..<5 {50 objects.append(b.createObject(with: ["a": intVal]))51 }52 // Next, temporarily overwrite the active code generators with the following generators...53 let createObjectGenerator = CodeGenerator("CreateObject") { b in54 let obj = b.createObject(with: ["a": intVal])55 objects.append(obj)56 }57 let propertyLoadGenerator = CodeGenerator("PropertyLoad", input: objType) { b, obj in58 assert(objects.contains(obj))59 b.loadProperty(chooseUniform(from: propertyNames), of: obj)60 }61 let propertyStoreGenerator = CodeGenerator("PropertyStore", input: objType) { b, obj in62 assert(objects.contains(obj))63 let numProperties = Int.random(in: 1...4)64 for _ in 0..<numProperties {65 b.storeProperty(chooseUniform(from: propertyValues), as: chooseUniform(from: propertyNames), on: obj)66 }67 }68 let functionDefinitionGenerator = CodeGenerator("FunctionDefinition") { b in69 let prevSize = objects.count70 b.definePlainFunction(withSignature: sig) { params in71 objects += params72 b.generateRecursive()73 b.doReturn(value: b.randVar(ofType: objType)!)74 }75 objects.removeLast(objects.count - prevSize)76 }77 let functionCallGenerator = CodeGenerator("FunctionCall", input: .function()) { b, f in78 let args = b.randCallArguments(for: sig)!79 assert(objects.contains(args[0]) && objects.contains(args[1]))80 let rval = b.callFunction(f, withArgs: args)81 assert(b.type(of: rval).Is(objType))82 objects.append(rval)83 }84 let functionJitCallGenerator = CodeGenerator("FunctionJitCall", input: .function()) { b, f in85 let args = b.randCallArguments(for: sig)!86 assert(objects.contains(args[0]) && objects.contains(args[1]))87 b.forLoop(b.loadInt(0), .lessThan, b.loadInt(100), .Add, b.loadInt(1)) { _ in88 b.callFunction(f, withArgs: args) // Rval goes out-of-scope immediately, so no need to track it89 }90 }91 let prevCodeGenerators = b.fuzzer.codeGenerators92 b.fuzzer.codeGenerators = WeightedList<CodeGenerator>([93 (createObjectGenerator, 1),94 (propertyLoadGenerator, 2),95 (propertyStoreGenerator, 5),96 (functionDefinitionGenerator, 1),97 (functionCallGenerator, 2),98 (functionJitCallGenerator, 1)99 ])100 // Disable splicing, as we only want the above code generators to run101 b.performSplicingDuringCodeGeneration = false102 // ... and generate a bunch of code, starting with a function so that103 // there is always at least one available for the call generators.104 b.run(functionDefinitionGenerator, recursiveCodegenBudget: 10)105 b.generate(n: 100)106 // Now, restore the previous code generators, re-enable splicing, and generate some more code107 b.fuzzer.codeGenerators = prevCodeGenerators108 b.performSplicingDuringCodeGeneration = true109 b.generate(n: 10)110 // Finally, run HeapObjectVerify on all our generated objects (that are still in scope)111 for obj in objects {112 b.eval("%HeapObjectVerify(%@)", with: [obj])113 }114}115// A variant of the JITFunction template that sprinkles calls to the %VerifyType builtin into the target function.116// Probably should be kept in sync with the original template.117fileprivate let VerifyTypeTemplate = ProgramTemplate("VerifyTypeTemplate") { b in118 let genSize = 3119 // Generate random function signatures as our helpers120 var functionSignatures = ProgramTemplate.generateRandomFunctionSignatures(forFuzzer: b.fuzzer, n: 2)121 // Generate random property types122 ProgramTemplate.generateRandomPropertyTypes(forBuilder: b)123 // Generate random method types124 ProgramTemplate.generateRandomMethodTypes(forBuilder: b, n: 2)125 b.generate(n: genSize)126 // Generate some small functions127 for signature in functionSignatures {128 // Here generate a random function type, e.g. arrow/generator etc129 b.definePlainFunction(withSignature: signature) { args in130 b.generate(n: genSize)131 }132 }133 // Generate a larger function134 let signature = ProgramTemplate.generateSignature(forFuzzer: b.fuzzer, n: 4)135 let f = b.definePlainFunction(withSignature: signature) { args in136 // Generate function body and sprinkle calls to %VerifyType137 for _ in 0..<10 {138 b.generate(n: 3)139 b.eval("%VerifyType(%@)", with: [b.randVar()])140 }141 }142 // Generate some random instructions now143 b.generate(n: genSize)144 // trigger JIT145 b.forLoop(b.loadInt(0), .lessThan, b.loadInt(100), .Add, b.loadInt(1)) { args in146 b.callFunction(f, withArgs: b.generateCallArguments(for: signature))147 }148 // more random instructions149 b.generate(n: genSize)150 b.callFunction(f, withArgs: b.generateCallArguments(for: signature))151 // maybe trigger recompilation152 b.forLoop(b.loadInt(0), .lessThan, b.loadInt(100), .Add, b.loadInt(1)) { args in153 b.callFunction(f, withArgs: b.generateCallArguments(for: signature))154 }155 // more random instructions156 b.generate(n: genSize)157 b.callFunction(f, withArgs: b.generateCallArguments(for: signature))158}159let v8Profile = Profile(160 processArguments: ["--expose-gc",161 // Uncomment to activate additional features that will be enabled in the future162 //"--future",163 "--allow-natives-syntax",164 "--interrupt-budget=1024",165 "--fuzzing"],166 processEnv: [:],167 codePrefix: """168 function placeholder(){return {};}169 function PrepareFunctionForOptimization(a){%PrepareFunctionForOptimization(a);}170 function OptimizeFunctionOnNextCall(a){%OptimizeFunctionOnNextCall(a);}171 function NeverOptimizeFunction(a){%NeverOptimizeFunction(a);}...

Full Screen

Full Screen

ResultGeneratorTests.swift

Source:ResultGeneratorTests.swift Github

copy

Full Screen

...5 private let fakeString = "Fake Fake"6 func testGenerateResultWhenEncoderTrhowAnerrorThenGenerateFailResult() {7 let data = try? JSONEncoder().encode(Fake(fake: fakeString))8 let resultGenerator = ResultGenerator<Fake>(decoder: DecoderThrowErrorFakeAdapter())9 let result = resultGenerator.generate(data: data, error: nil)10 XCTAssertEqual(result.error, .noData)11 }12 func testGenerateResultWhenInvalidDataThenGenerateSuccessResult() {13 let noDataError = FrisbeeError.noData14 let data = try? JSONEncoder().encode(Data())15 let resultGenerator: ResultGenerator<Fake> = ResultGeneratorFactory.make()16 let result = resultGenerator.generate(data: data, error: nil)17 XCTAssertEqual(result.error, noDataError)18 }19 func testGenerateResultWhenHasDataThenGenerateSuccessResult() {20 let data = try? JSONEncoder().encode(Fake(fake: fakeString))21 let resultGenerator: ResultGenerator<Fake> = ResultGeneratorFactory.make()22 let result = resultGenerator.generate(data: data, error: nil)23 XCTAssertEqual(result.data?.fake, fakeString)24 }25 func testGenerateResultWhenHasDataThenResultFailErrorIsNil() {26 let data = try? JSONEncoder().encode(Fake(fake: fakeString))27 let resultGenerator: ResultGenerator<Fake> = ResultGeneratorFactory.make()28 let result = resultGenerator.generate(data: data, error: nil)29 XCTAssertNil(result.error)30 }31 func testGenerateResultWhenHasNilDataThenGenerateNoDataErrorResult() {32 let noDataError = Result<Data>.fail(FrisbeeError.noData)33 let resultGenerator: ResultGenerator<Data> = ResultGeneratorFactory.make()34 let result = resultGenerator.generate(data: nil, error: nil)35 XCTAssertEqual(result, noDataError)36 }37 func testGenerateResultWhenHasNilDataThenResultSuccessDataIsNil() {38 let resultGenerator: ResultGenerator<Data> = ResultGeneratorFactory.make()39 let result = resultGenerator.generate(data: nil, error: nil)40 XCTAssertNil(result.data)41 }42 func testGenerateResultWhenHasErrorThenGenerateErrorResult() {43 let resultGenerator: ResultGenerator<Data> = ResultGeneratorFactory.make()44 let noDataError = FrisbeeError.other(localizedDescription: someError.localizedDescription)45 let result = resultGenerator.generate(data: nil, error: someError)46 XCTAssertEqual(result.error, noDataError)47 }48 func testGenerateResultWhenHasErrorThenResultSuccessDataIsNil() {49 let resultGenerator: ResultGenerator<Data> = ResultGeneratorFactory.make()50 let result = resultGenerator.generate(data: nil, error: someError)51 XCTAssertNil(result.data)52 }53 static var allTests = [54 ("testGenerateResultWhenEncoderTrhowAnerrorThenGenerateFailResult",55 testGenerateResultWhenEncoderTrhowAnerrorThenGenerateFailResult),56 ("testGenerateResultWhenHasDataThenGenerateSuccessResult",57 testGenerateResultWhenHasDataThenGenerateSuccessResult),58 ("testGenerateResultWhenHasDataThenResultFailErrorIsNil",59 testGenerateResultWhenHasDataThenResultFailErrorIsNil),60 ("testGenerateResultWhenHasNilDataThenGenerateNoDataErrorResult",61 testGenerateResultWhenHasNilDataThenGenerateNoDataErrorResult),62 ("testGenerateResultWhenHasNilDataThenResultSuccessDataIsNil",63 testGenerateResultWhenHasNilDataThenResultSuccessDataIsNil),64 ("testGenerateResultWhenHasErrorThenGenerateErrorResult",...

Full Screen

Full Screen

HOTPGeneratorTests.swift

Source:HOTPGeneratorTests.swift Github

copy

Full Screen

...34 ])35 }36 // Test oracle was obatined from http://www.foo.be/hotp/example.html37 func testGenerateDec6() {38 XCTAssertEqual("755224", generator.generate(at: 0, format: .dec6))39 XCTAssertEqual("287082", generator.generate(at: 1, format: .dec6))40 XCTAssertEqual("359152", generator.generate(at: 2, format: .dec6))41 XCTAssertEqual("969429", generator.generate(at: 3, format: .dec6))42 XCTAssertEqual("338314", generator.generate(at: 4, format: .dec6))43 XCTAssertEqual("254676", generator.generate(at: 5, format: .dec6))44 XCTAssertEqual("287922", generator.generate(at: 6, format: .dec6))45 XCTAssertEqual("162583", generator.generate(at: 7, format: .dec6))46 XCTAssertEqual("399871", generator.generate(at: 8, format: .dec6))47 XCTAssertEqual("520489", generator.generate(at: 9, format: .dec6))48 }49 func testGenerateDec8() {50 XCTAssertEqual("84755224", generator.generate(at: 0, format: .dec8))51 XCTAssertEqual("94287082", generator.generate(at: 1, format: .dec8))52 XCTAssertEqual("37359152", generator.generate(at: 2, format: .dec8))53 XCTAssertEqual("26969429", generator.generate(at: 3, format: .dec8))54 XCTAssertEqual("40338314", generator.generate(at: 4, format: .dec8))55 XCTAssertEqual("68254676", generator.generate(at: 5, format: .dec8))56 XCTAssertEqual("18287922", generator.generate(at: 6, format: .dec8))57 XCTAssertEqual("82162583", generator.generate(at: 7, format: .dec8))58 XCTAssertEqual("73399871", generator.generate(at: 8, format: .dec8))59 XCTAssertEqual("45520489", generator.generate(at: 9, format: .dec8))60 }61}...

Full Screen

Full Screen

generate

Using AI Code Generation

copy

Full Screen

1let generator = Generator()2generator.generate()3let generator = Generator()4generator.generate()5let generator = Generator()6generator.generate()7let generator = Generator()8generator.generate()9let generator = Generator()10generator.generate()11let generator = Generator()12generator.generate()13let generator = Generator()14generator.generate()15let generator = Generator()16generator.generate()17let generator = Generator()18generator.generate()19let generator = Generator()20generator.generate()21let generator = Generator()22generator.generate()23let generator = Generator()24generator.generate()25let generator = Generator()26generator.generate()27let generator = Generator()28generator.generate()29let generator = Generator()30generator.generate()31let generator = Generator()32generator.generate()33let generator = Generator()34generator.generate()35let generator = Generator()36generator.generate()37let generator = Generator()38generator.generate()39let generator = Generator()40generator.generate()

Full Screen

Full Screen

generate

Using AI Code Generation

copy

Full Screen

1let generator = Generator()2let generated = generator.generate()3let generator = Generator()4let generated = generator.generate()5let generator = Generator()6let generated = generator.generate()7let generator = Generator()8let generated = generator.generate()9let generator = Generator()10let generated = generator.generate()11let generator = Generator()12let generated = generator.generate()13let generator = Generator()14let generated = generator.generate()15let generator = Generator()16let generated = generator.generate()17let generator = Generator()18let generated = generator.generate()19let generator = Generator()20let generated = generator.generate()21let generator = Generator()22let generated = generator.generate()23let generator = Generator()24let generated = generator.generate()25let generator = Generator()26let generated = generator.generate()27let generator = Generator()28let generated = generator.generate()29let generator = Generator()30let generated = generator.generate()31let generator = Generator()32let generated = generator.generate()33let generator = Generator()34let generated = generator.generate()35let generator = Generator()36let generated = generator.generate()

Full Screen

Full Screen

generate

Using AI Code Generation

copy

Full Screen

1let generator = Generator()2let result = generator.generate()3let generator = Generator()4let result = generator.generate()5let generator = Generator()6let result = generator.generate()7let generator = Generator()8let result = generator.generate()9let generator = Generator()10let result = generator.generate()11let generator = Generator()12let result = generator.generate()13let generator = Generator()14let result = generator.generate()15let generator = Generator()16let result = generator.generate()17let generator = Generator()18let result = generator.generate()19let generator = Generator()20let result = generator.generate()21let generator = Generator()22let result = generator.generate()23let generator = Generator()24let result = generator.generate()25let generator = Generator()26let result = generator.generate()27let generator = Generator()28let result = generator.generate()29let generator = Generator()30let result = generator.generate()31let generator = Generator()32let result = generator.generate()33let generator = Generator()34let result = generator.generate()35let generator = Generator()36let result = generator.generate()

Full Screen

Full Screen

generate

Using AI Code Generation

copy

Full Screen

1let gen = Generator()2let random = gen.generate()3print(random)4let gen = Generator()5let random = gen.generate()6print(random)7let gen = Generator()8let random = gen.generate()9print(random)10let gen = Generator()11let random = gen.generate()12print(random)13let gen = Generator()14let random = gen.generate()15print(random)16let gen = Generator()17let random = gen.generate()18print(random)19let gen = Generator()20let random = gen.generate()21print(random)22let gen = Generator()23let random = gen.generate()24print(random)25let gen = Generator()26let random = gen.generate()27print(random)28let gen = Generator()29let random = gen.generate()30print(random)31let gen = Generator()32let random = gen.generate()33print(random)34let gen = Generator()35let random = gen.generate()36print(random)37let gen = Generator()38let random = gen.generate()39print(random)40let gen = Generator()41let random = gen.generate()42print(random)43let gen = Generator()44let random = gen.generate()45print(random)46let gen = Generator()47let random = gen.generate()48print(random)

Full Screen

Full Screen

generate

Using AI Code Generation

copy

Full Screen

1import Foundation2func generate() {3 let generator = Generator()4 let result = generator.generate()5 print(result)6}7generate()8import Foundation9func generate() {10 let generator = Generator()11 let result = generator.generate()12 print(result)13}14generate()15import Foundation16func generate() {17 let generator = Generator()18 let result = generator.generate()19 print(result)20}21generate()22import Foundation23func generate() {24 let generator = Generator()25 let result = generator.generate()26 print(result)27}28generate()29import Foundation30func generate() {31 let generator = Generator()32 let result = generator.generate()33 print(result)34}35generate()36import Foundation37func generate() {38 let generator = Generator()39 let result = generator.generate()40 print(result)41}42generate()43import Foundation44func generate() {45 let generator = Generator()46 let result = generator.generate()47 print(result)48}49generate()50import Foundation51func generate() {52 let generator = Generator()53 let result = generator.generate()54 print(result)55}56generate()57import Foundation58func generate() {59 let generator = Generator()60 let result = generator.generate()61 print(result)62}63generate()64import Foundation65func generate() {66 let generator = Generator()67 let result = generator.generate()68 print(result)69}70generate()71import Foundation72func generate() {73 let generator = Generator()74 let result = generator.generate()75 print(result)76}77generate()78import Foundation79func generate() {80 let generator = Generator()

Full Screen

Full Screen

generate

Using AI Code Generation

copy

Full Screen

1import Foundation2let generator = Generator()3let random = generator.generate()4print(random)5import Foundation6let generator = Generator()7let random = generator.generate()8print(random)9import Foundation10let generator = Generator()11let random = generator.generate()12print(random)13import Foundation14let generator = Generator()15let random = generator.generate()16print(random)17import Foundation18let generator = Generator()19let random = generator.generate()20print(random)21import Foundation22let generator = Generator()23let random = generator.generate()24print(random)25import Foundation26let generator = Generator()27let random = generator.generate()28print(random)29import Foundation30let generator = Generator()31let random = generator.generate()32print(random)33import Foundation34let generator = Generator()35let random = generator.generate()36print(random)37import Foundation38let generator = Generator()39let random = generator.generate()40print(random)41import Foundation42let generator = Generator()43let random = generator.generate()44print(random)45import Foundation46let generator = Generator()47let random = generator.generate()48print(random)49import Foundation50let generator = Generator()51let random = generator.generate()52print(random)53import Foundation54let generator = Generator()55let random = generator.generate()56print(random)57import Foundation58let generator = Generator()59let random = generator.generate()60print(random)61import Foundation62let generator = Generator()63let random = generator.generate()64print(random)65import Foundation66let generator = Generator()67let random = generator.generate()68print(random)69import Foundation70let generator = Generator()71let random = generator.generate()72print(random)73import Foundation74let generator = Generator()75let random = generator.generate()76print(random)77import Foundation78let generator = Generator()79let random = generator.generate()80print(random)81import Foundation82let generator = Generator()83let random = generator.generate()84print(random)

Full Screen

Full Screen

generate

Using AI Code Generation

copy

Full Screen

1let g = Generator()2let randomArray = g.generate(10)3print(randomArray)4let g = Generator()5let randomArray = g.generate(10)6print(randomArray)7let g = Generator()8let randomArray = g.generate(10)9print(randomArray)10let g = Generator()11let randomArray = g.generate(10)12print(randomArray)13let g = Generator()14let randomArray = g.generate(10)15print(randomArray)16let g = Generator()17let randomArray = g.generate(10)18print(randomArray)19let g = Generator()20let randomArray = g.generate(10)21print(randomArray)22let g = Generator()23let randomArray = g.generate(10)24print(randomArray)25let g = Generator()26let randomArray = g.generate(10)27print(randomArray)28let g = Generator()29let randomArray = g.generate(10)30print(randomArray)31let g = Generator()32let randomArray = g.generate(10)33print(randomArray)34let g = Generator()35let randomArray = g.generate(10)36print(randomArray)37let g = Generator()38let randomArray = g.generate(10)39print(randomArray)40let g = Generator()41let randomArray = g.generate(10)42print(randomArray)43let g = Generator()

Full Screen

Full Screen

generate

Using AI Code Generation

copy

Full Screen

1import Foundation2let generator = Generator()3let generatedString = generator.generate()4print(generatedString)5import Foundation6let generator = Generator()7let generatedString = generator.generate()8print(generatedString)9import Foundation10let generator = Generator()11let generatedString = generator.generate()12print(generatedString)13import Foundation14let generator = Generator()15let generatedString = generator.generate()16print(generatedString)17import Foundation18let generator = Generator()19let generatedString = generator.generate()20print(generatedString)21import Foundation22let generator = Generator()23let generatedString = generator.generate()24print(generatedString)25import Foundation26let generator = Generator()27let generatedString = generator.generate()28print(generatedString)29import Foundation30let generator = Generator()31let generatedString = generator.generate()32print(generatedString)33import Foundation34let generator = Generator()35let generatedString = generator.generate()36print(generatedString)37import Foundation38let generator = Generator()39let generatedString = generator.generate()40print(generatedString)41import Foundation42let generator = Generator()43let generatedString = generator.generate()44print(generatedString)45import Foundation46let generator = Generator()47let generatedString = generator.generate()48print(generatedString

Full Screen

Full Screen

generate

Using AI Code Generation

copy

Full Screen

1import Foundation2let generator = Generator()3let generatedString = generator.generate()4print(generatedString)5import Foundation6let generator = Generator()7let generatedString = generator.generate()8print(generatedString)9import Foundation10let generator = Generator()11let generatedString = generator.generate()12print(generatedString)13import Foundation14let generator = Generator()15let generatedString = generator.generate()16print(generatedString)17import Foundation18let generator = Generator()19let generatedString = generator.generate()20print(generatedString)21import Foundation22let generator = Generator()23let generatedString = generator.generate()24print(generatedString)25import Foundation26let generator = Generator()27let generatedString = generator.generate()28print(generatedString)29import Foundation30let generator = Generator()31let generatedString = generator.generate()32print(generatedString)33import Foundation34let generator = Generator()35let generatedString = generator.generate()36print(generatedString)37import Foundation38let generator = Generator()39let generatedString = generator.generate()40print(generatedString)41import Foundation42let generator = Generator()43let generatedString = generator.generate()44print(generatedString)45import Foundation46let generator = Generator()47let generatedString = generator.generate()48print(generatedString

Full Screen

Full Screen

generate

Using AI Code Generation

copy

Full Screen

1let generator = Generator()2var array = generator.generateArray(5)3let generator = Generator()4var array = generator.generateArray(5)5let generator = Generator()6var array = generator.generateArray(5)7let generator = Generator()8var array = generator.generateArray(5)9let generator = Generator()10var array = generator.generateArray(5)11let generator = Generator()12var array = generator.generateArray(5)13let generator = Generator()14var array = generator.generateArray(5)15let generator = Generator()16var array = generator.generateArray(5)17let generator = Generator()18var array = generator.generateArray(5)19let generator = Generator()20var array = generator.generateArray(5)21let generator = Generator()22var array = generator.generateArray(5)23let generator = Generator()24var array = generator.generateArray(5)25let generator = Generator()26var array = generator.generateArray(5)27let generator = Generator()28var array = generator.generateArray(5)29let generator = Generator()30var array = generator.generateArray(5)31let generator = Generator()32var array = generator.generateArray(5)

Full Screen

Full Screen

generate

Using AI Code Generation

copy

Full Screen

1let g = Generator()2let randomArray = g.generate(10)3print(randomArray)4let g = Generator()5let randomArray = g.generate(10)6print(randomArray)7let g = Generator()8let randomArray = g.generate(10)9print(randomArray)10let g = Generator()11let randomArray = g.generate(10)12print(randomArray)13let g = Generator()14let randomArray = g.generate(10)15print(randomArray)16let g = Generator()17let randomArray = g.generate(10)18print(randomArray)19let g = Generator()20let randomArray = g.generate(10)21print(randomArray)22let g = Generator()23let randomArray = g.generate(10)24print(randomArray)25let g = Generator()26let randomArray = g.generate(10)27print(randomArray)28let g = Generator()29let randomArray = g.generate(10)30print(randomArray)31let g = Generator()32let randomArray = g.generate(10)33print(randomArray)34let g = Generator()35let randomArray = g.generate(10)36print(randomArray)37let g = Generator()38let randomArray = g.generate(10)39print(randomArray)40let g = Generator()41let randomArray = g.generate(10)42print(randomArray)43let g = Generator()

Full Screen

Full Screen

generate

Using AI Code Generation

copy

Full Screen

1let generator = Generator()2var array = generator.generateArray(5)3let generator = Generator()4var array = generator.generateArray(5)5let generator = Generator()6var array = generator.generateArray(5)7let generator = Generator()8var array = generator.generateArray(5)9let generator = Generator()10var array = generator.generateArray(5)11let generator = Generator()12var array = generator.generateArray(5)13let generator = Generator()14var array = generator.generateArray(5)15let generator = Generator()16var array = generator.generateArray(5)17let generator = Generator()18var array = generator.generateArray(5)19let generator = Generator()20var array = generator.generateArray(5)21let generator = Generator()22var array = generator.generateArray(5)23let generator = Generator()24var array = generator.generateArray(5)25let generator = Generator()26var array = generator.generateArray(5)27let generator = Generator()28var array = generator.generateArray(5)29let generator = Generator()30var array = generator.generateArray(5)31let generator = Generator()32var array = generator.generateArray(5)

Full Screen

Full Screen

generate

Using AI Code Generation

copy

Full Screen

1import UIKit2class Generator: NSObject {3 func generate() -> [String] {4 }5}6let generator = Generator()7let result = generator.generate()8print(result)9import UIKit10class Generator: NSObject {11 func generate() -> [String] {12 }13}14let generator = Generator()15let result = generator.generate()16print(result)17import UIKit18class Generator: NSObject {19 func generate() -> [String] {20 }21}22let generator = Generator()23let result = generator.generate()24print(result)25import UIKit26class Generator: NSObject {27 func generate() -> [String] {28 }29}30let generator = Generator()31let result = generator.generate()32print(result)33import UIKit34class Generator: NSObject {35 func generate() -> [String] {36 }37}38let generator = Generator()39let result = generator.generate()40print(result)41import UIKit42class Generator: NSObject {43 func generate() -> [String] {44 }45}46let generator = Generator()47let result = generator.generate()48print(result)49import UIKit50class Generator: NSObject {51 func generate() -> [String] {52 }53}54let generator = Generator()55let result = generator.generate()56print(result)57import UIKit58class Generator: NSObject {59 func generate() -> [String] {60 }61}62let generator = Generator()63let result = generator.generate()64print(result)65import UIKit

Full Screen

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