Best JavaScript code snippet using ng-mocks
t_pkg_list.py
Source:t_pkg_list.py
1#!/usr/bin/python2#3# CDDL HEADER START4#5# The contents of this file are subject to the terms of the6# Common Development and Distribution License (the "License").7# You may not use this file except in compliance with the License.8#9# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE10# or http://www.opensolaris.org/os/licensing.11# See the License for the specific language governing permissions12# and limitations under the License.13#14# When distributing Covered Code, include this CDDL HEADER in each15# file and include the License file at usr/src/OPENSOLARIS.LICENSE.16# If applicable, add the following below this CDDL HEADER, with the17# fields enclosed by brackets "[]" replaced with your own identifying18# information: Portions Copyright [yyyy] [name of copyright owner]19#20# CDDL HEADER END21#22#23# Copyright (c) 2008, 2016, Oracle and/or its affiliates. All rights reserved.24#25from . import testutils26if __name__ == "__main__":27 testutils.setup_environment("../../../proto")28import pkg5unittest29import os30import pkg.fmri as fmri31import pkg.manifest as manifest32import unittest33class TestPkgList(pkg5unittest.ManyDepotTestCase):34 # Only start/stop the depot once (instead of for every test)35 persistent_setup = True36 foo1 = """37 open foo@1,5.11-038 close """39 foo10 = """40 open foo@1.0,5.11-041 close """42 foo11 = """43 open foo@1.1,5.11-044 close """45 foo12 = """46 open foo@1.2,5.11-047 close """48 foo121 = """49 open foo@1.2.1,5.11-050 close """51 food12 = """52 open food@1.2,5.11-053 close """54 newpkg10 = """55 open newpkg@1.056 close """57 hierfoo10 = """58 open hier/foo@1.0,5.11-059 close """60 def __check_qoutput(self, errout=False):61 self.assertEqualDiff(self.output, "")62 if errout:63 self.assertTrue(self.errout != "",64 "-q must print fatal errors!")65 else:66 self.assertTrue(self.errout == "",67 "-q should only print fatal errors!")68 def setUp(self):69 pkg5unittest.ManyDepotTestCase.setUp(self, ["test1", "test2",70 "test2"])71 self.rurl1 = self.dcs[1].get_repo_url()72 self.pkgsend_bulk(self.rurl1, (self.foo1, self.foo10,73 self.foo11, self.foo12, self.foo121, self.food12,74 self.hierfoo10))75 # Ensure that the second repo's packages have exactly the same76 # timestamps as those in the first ... by copying the repo over.77 # If the repos need to have some contents which are different,78 # send those changes after restarting depot 2.79 d1dir = self.dcs[1].get_repodir()80 d2dir = self.dcs[2].get_repodir()81 self.copy_repository(d1dir, d2dir, { "test1": "test2" })82 # The new repository won't have a catalog, so rebuild it.83 self.dcs[2].get_repo(auto_create=True).rebuild()84 # The third repository should remain empty and not be85 # published to.86 # Next, create the image and configure publishers.87 self.image_create(self.rurl1, prefix="test1")88 self.rurl2 = self.dcs[2].get_repo_url()89 self.pkg("set-publisher -O " + self.rurl2 + " test2")90 self.rurl3 = self.dcs[3].get_repo_url()91 def test_pkg_list_cli_opts(self):92 self.pkg("list -@", exit=2)93 self.pkg("list -v -s", exit=2)94 self.pkg("list -a -u", exit=2)95 self.pkg("list -g pkg://test1/ -u", exit=2)96 # Should only print fatal errors when using -q.97 self.pkg("list -q -v", exit=2)98 self.__check_qoutput(errout=True)99 def test_00(self):100 """Verify that sort order and content of a full list matches101 expected."""102 self.pkg("list -aH")103 expected = \104 ("foo 1.2.1-0 ---\n"105 "foo (test2) 1.2.1-0 ---\n"106 "food 1.2-0 ---\n"107 "food (test2) 1.2-0 ---\n"108 "hier/foo 1.0-0 ---\n"109 "hier/foo (test2) 1.0-0 ---\n")110 output = self.reduceSpaces(self.output)111 self.assertEqualDiff(expected, output)112 # Should only print fatal errors when using -q.113 self.pkg("list -aqH")114 self.__check_qoutput(errout=False)115 self.pkg("list -afH")116 expected = \117 ("foo 1.2.1-0 ---\n"118 "foo 1.2-0 ---\n"119 "foo 1.1-0 ---\n"120 "foo 1.0-0 ---\n"121 "foo 1-0 ---\n"122 "foo (test2) 1.2.1-0 ---\n"123 "foo (test2) 1.2-0 ---\n"124 "foo (test2) 1.1-0 ---\n"125 "foo (test2) 1.0-0 ---\n"126 "foo (test2) 1-0 ---\n"127 "food 1.2-0 ---\n"128 "food (test2) 1.2-0 ---\n"129 "hier/foo 1.0-0 ---\n"130 "hier/foo (test2) 1.0-0 ---\n")131 output = self.reduceSpaces(self.output)132 self.assertEqualDiff(expected, output)133 # Put options in different order to ensure output still matches.134 self.pkg("list -faH")135 output = self.reduceSpaces(self.output)136 self.assertEqualDiff(expected, output)137 def test_01(self):138 """List all "foo@1.0" from auth "test1"."""139 self.pkg("list -afH pkg://test1/foo@1.0,5.11-0")140 expected = \141 "foo 1.0-0 ---\n"142 output = self.reduceSpaces(self.output)143 self.assertEqualDiff(expected, output)144 # Test 'rooted' name.145 self.pkg("list -afH //test1/foo@1.0,5.11-0")146 output = self.reduceSpaces(self.output)147 self.assertEqualDiff(expected, output)148 def test_02(self):149 """List all "foo@1.0", regardless of publisher, with "pkg:/"150 or '/' prefix."""151 self.pkg("list -afH pkg:/foo@1.0,5.11-0")152 expected = \153 "foo 1.0-0 ---\n" \154 "foo (test2) 1.0-0 ---\n"155 output = self.reduceSpaces(self.output)156 self.assertEqualDiff(expected, output)157 # Test 'rooted' name.158 self.pkg("list -afH /foo@1.0,5.11-0")159 output = self.reduceSpaces(self.output)160 self.assertEqualDiff(expected, output)161 def test_03(self):162 """List all "foo@1.0", regardless of publisher, without "pkg:/"163 prefix."""164 self.pkg("list -afH pkg:/foo@1.0,5.11-0")165 expected = \166 "foo 1.0-0 ---\n" \167 "foo (test2) 1.0-0 ---\n"168 output = self.reduceSpaces(self.output)169 expected = self.reduceSpaces(expected)170 self.assertEqualDiff(expected, output)171 def test_04(self):172 """List all versions of package foo, regardless of publisher."""173 self.pkg("list -aHf foo")174 expected = \175 "foo 1.2.1-0 ---\n" \176 "foo 1.2-0 ---\n" \177 "foo 1.1-0 ---\n" \178 "foo 1.0-0 ---\n" \179 "foo 1-0 ---\n" \180 "foo (test2) 1.2.1-0 ---\n" \181 "foo (test2) 1.2-0 ---\n" \182 "foo (test2) 1.1-0 ---\n" \183 "foo (test2) 1.0-0 ---\n" \184 "foo (test2) 1-0 ---\n" \185 "hier/foo 1.0-0 ---\n" \186 "hier/foo (test2) 1.0-0 ---\n"187 output = self.reduceSpaces(self.output)188 expected = self.reduceSpaces(expected)189 self.assertEqualDiff(expected, output)190 self.pkg("list -aH foo")191 expected = \192 "foo 1.2.1-0 ---\n" \193 "foo (test2) 1.2.1-0 ---\n" \194 "hier/foo 1.0-0 ---\n" \195 "hier/foo (test2) 1.0-0 ---\n"196 output = self.reduceSpaces(self.output)197 expected = self.reduceSpaces(expected)198 self.assertEqualDiff(expected, output)199 def test_05(self):200 """Show foo@1.0 from both depots, but 1.1 only from test2."""201 self.pkg("list -aHf foo@1.0-0 pkg://test2/foo@1.1-0")202 expected = \203 "foo 1.0-0 ---\n" \204 "foo (test2) 1.1-0 ---\n" \205 "foo (test2) 1.0-0 ---\n" \206 "hier/foo 1.0-0 ---\n" \207 "hier/foo (test2) 1.0-0 ---\n"208 output = self.reduceSpaces(self.output)209 expected = self.reduceSpaces(expected)210 self.assertEqualDiff(expected, output)211 self.pkg("list -aHf foo@1.0-0 pkg://test2/foo@1.1-0")212 expected = \213 "foo 1.0-0 ---\n" \214 "foo (test2) 1.1-0 ---\n" \215 "foo (test2) 1.0-0 ---\n" \216 "hier/foo 1.0-0 ---\n" \217 "hier/foo (test2) 1.0-0 ---\n"218 output = self.reduceSpaces(self.output)219 expected = self.reduceSpaces(expected)220 self.assertEqualDiff(expected, output)221 def test_06(self):222 """Show versions 1.0 and 1.1 of foo only from publisher test2."""223 self.pkg("list -aHf pkg://test2/foo")224 expected = \225 "foo (test2) 1.2.1-0 ---\n" \226 "foo (test2) 1.2-0 ---\n" \227 "foo (test2) 1.1-0 ---\n" \228 "foo (test2) 1.0-0 ---\n" \229 "foo (test2) 1-0 ---\n"230 output = self.reduceSpaces(self.output)231 expected = self.reduceSpaces(expected)232 self.assertEqualDiff(expected, output)233 self.pkg("list -aH pkg://test2/foo")234 expected = \235 "foo (test2) 1.2.1-0 ---\n"236 output = self.reduceSpaces(self.output)237 expected = self.reduceSpaces(expected)238 self.assertEqualDiff(expected, output)239 def test_07(self):240 """List all foo@1 from test1, but all foo@1.2(.x), and only list241 the latter once."""242 self.pkg("list -aHf pkg://test1/foo@1 pkg:/foo@1.2")243 expected = \244 "foo 1.2.1-0 ---\n" \245 "foo 1.2-0 ---\n" \246 "foo 1.1-0 ---\n" \247 "foo 1.0-0 ---\n" \248 "foo 1-0 ---\n" \249 "foo (test2) 1.2.1-0 ---\n" \250 "foo (test2) 1.2-0 ---\n"251 output = self.reduceSpaces(self.output)252 expected = self.reduceSpaces(expected)253 self.assertEqualDiff(expected, output)254 self.pkg("list -aH pkg://test1/foo@1 pkg:/foo@1.2")255 expected = \256 "foo 1.2.1-0 ---\n" + \257 "foo (test2) 1.2.1-0 ---\n"258 output = self.reduceSpaces(self.output)259 expected = self.reduceSpaces(expected)260 self.assertEqualDiff(expected, output)261 def test_08_after_pub_update_removal(self):262 """Install a package from a publisher which is also offered by263 another publisher. Then alter or remove the installed package's264 publisher, and verify that list still shows the package265 as installed."""266 self.pkg("list -a")267 # Install a package from the second publisher.268 self.pkg("install pkg://test2/foo@1.0")269 # Should only print fatal errors when using -q.270 self.pkg("list -q foo")271 self.__check_qoutput(errout=False)272 self.pkg("list -q foo bogus", exit=3)273 self.__check_qoutput(errout=False)274 # Change the origin of the publisher of an installed package to275 # that of an empty repository. The package should still be276 # shown for test1 and installed for test2.277 self.pkg("set-publisher -O {0} test2".format(self.rurl3))278 self.pkg("list -aHf /foo@1.0")279 expected = \280 "foo 1.0-0 ---\n" + \281 "foo (test2) 1.0-0 i--\n"282 output = self.reduceSpaces(self.output)283 self.assertEqualDiff(expected, output)284 self.pkg("set-publisher -O {0} test2".format(self.rurl2))285 # Remove the publisher of an installed package, then add the286 # publisher back, but with an empty repository. The package287 # should still be shown as for test1 and installed for test2.288 self.pkg("unset-publisher test2")289 self.pkg("set-publisher -O {0} test2".format(self.rurl3))290 self.pkg("list -aHf /foo@1.0")291 expected = \292 "foo 1.0-0 ---\n" + \293 "foo (test2) 1.0-0 i--\n"294 output = self.reduceSpaces(self.output)295 self.assertEqualDiff(expected, output)296 self.pkg("set-publisher -O {0} test2".format(self.rurl2))297 # With the publisher of an installed package unknown, add a new298 # publisher using the repository the package was originally299 # installed from. The pkg should be shown as for test1,300 # installed for test2, and test3 shouldn't be listed since the301 # packages in the specified repository are for publisher test2.302 self.pkg("unset-publisher test2")303 # Uninstall the package so any remaining tests won't be304 # impacted.305 self.pkg("uninstall pkg://test2/foo@1.0")306 def test_09_needs_refresh(self):307 """Verify that a list operation performed when a publisher's308 metadata needs refresh works as expected."""309 # Package should not exist as an unprivileged user or as a310 # privileged user since it hasn't been published yet.311 self.pkg("list -a | grep newpkg", su_wrap=True, exit=1)312 self.pkg("list -a | grep newpkg", exit=1)313 # Should only print fatal errors when using -q.314 self.pkg("list -aq newpkg", exit=1)315 self.__check_qoutput(errout=False)316 self.pkgsend_bulk(self.rurl1, self.newpkg10)317 # Package should not exist as an unprivileged user or as a318 # privileged user since the publisher doesn't need a refresh319 # yet.320 self.pkg("list -a | grep newpkg", su_wrap=True, exit=1)321 self.pkg("list -a | grep newpkg", exit=1)322 # Remove the last_refreshed file for one of the publishers so323 # that it will be seen as needing refresh.324 api_inst = self.get_img_api_obj()325 pub = api_inst.get_publisher("test1")326 os.remove(os.path.join(pub.meta_root, "last_refreshed"))327 # Package should not exist as an unprivileged user since the328 # metadata for the publisher has not yet been refreshed and329 # cannot be.330 self.pkg("list -a | grep newpkg", su_wrap=True, exit=1)331 # pkg list should work as an unprivileged user even though one332 # or more publishers need their metadata refreshed.333 self.pkg("list -a", su_wrap=True)334 # Package should exist as a privileged user since the metadata335 # for the publisher needs to be refreshed and can be.336 self.pkg("list -a | grep newpkg")337 # Package should now exist for unprivileged user since the338 # metadata has been refreshed.339 self.pkg("list -a | grep newpkg", su_wrap=True)340 # Should only print fatal errors when using -q.341 self.pkg("list -aq newpkg")342 self.__check_qoutput(errout=False)343 def test_symlink_last_refreshed(self):344 """Verify that we generate an error if the path to the345 last_refreshed file contains a symlink."""346 # Remove the last_refreshed file for one of the publishers so347 # that it will be seen as needing refresh.348 api_inst = self.get_img_api_obj()349 pub = api_inst.get_publisher("test1")350 351 file_path = os.path.join(pub.meta_root, "last_refreshed")352 tmp_file = os.path.join(pub.meta_root, "test_symlink")353 os.remove(file_path)354 # We will create last_refreshed as symlink to verify with355 # pkg operations.356 fo = open(tmp_file, 'wb+')357 fo.close()358 os.symlink(tmp_file, file_path)359 360 # Verify that both pkg install and refresh generate an error361 # if the last_refreshed file is a symlink.362 self.pkg("install newpkg@1.0", su_wrap=False, exit=1)363 self.assertTrue("contains a symlink" in self.errout)364 self.pkg("refresh test1", su_wrap=False, exit=1)365 self.assertTrue("contains a symlink" in self.errout)366 # Remove the temporary file and the lock file367 os.remove(tmp_file)368 os.remove(file_path)369 def test_10_all_known_failed_refresh(self):370 """Verify that a failed implicit refresh will not prevent pkg371 list from working properly when appropriate."""372 # Set test2's origin to an unreachable URI.373 self.pkg("set-publisher --no-refresh -O http://test.invalid2 "374 "test2")375 # Verify pkg list -a works as expected for an unprivileged user376 # when a permissions failure is encountered.377 self.pkg("list -a", su_wrap=True)378 # Verify pkg list -a fails for a privileged user when a379 # publisher's repository is unreachable.380 self.pkg("list -a", exit=1)381 # Should only print fatal errors when using -q.382 self.pkg("list -aq newpkg", exit=1)383 self.__check_qoutput(errout=True)384 # Reset test2's origin.385 self.pkg("set-publisher -O {0} test2".format(self.rurl2))386 def test_12_matching(self):387 """Verify that pkg list pattern matching works as expected."""388 self.pkg("publisher")389 self.pkg("list -aHf 'foo*'")390 expected = \391 "foo 1.2.1-0 ---\n" \392 "foo 1.2-0 ---\n" \393 "foo 1.1-0 ---\n" \394 "foo 1.0-0 ---\n" \395 "foo 1-0 ---\n" \396 "foo (test2) 1.2.1-0 ---\n" \397 "foo (test2) 1.2-0 ---\n" \398 "foo (test2) 1.1-0 ---\n" \399 "foo (test2) 1.0-0 ---\n" \400 "foo (test2) 1-0 ---\n" \401 "food 1.2-0 ---\n" \402 "food (test2) 1.2-0 ---\n"403 output = self.reduceSpaces(self.output)404 expected = self.reduceSpaces(expected)405 self.assertEqualDiff(expected, output)406 self.pkg("list -aHf '/fo*'")407 output = self.reduceSpaces(self.output)408 self.assertEqualDiff(expected, output)409 self.pkg("list -aHf 'f?o*'")410 output = self.reduceSpaces(self.output)411 self.assertEqualDiff(expected, output)412 expected += \413 "hier/foo 1.0-0 ---\n" \414 "hier/foo (test2) 1.0-0 ---\n"415 expected = self.reduceSpaces(expected)416 self.pkg("list -aHf '*fo*'")417 output = self.reduceSpaces(self.output)418 self.assertEqualDiff(expected, output)419 self.pkg("list -aH 'foo*'")420 expected = \421 "foo 1.2.1-0 ---\n" \422 "foo (test2) 1.2.1-0 ---\n" \423 "food 1.2-0 ---\n" \424 "food (test2) 1.2-0 ---\n" \425 output = self.reduceSpaces(self.output)426 expected = self.reduceSpaces(expected)427 self.assertEqualDiff(expected, output)428 self.pkg("list -aH '/fo*'")429 output = self.reduceSpaces(self.output)430 self.assertEqualDiff(expected, output)431 self.pkg("list -aH 'f?o*'")432 output = self.reduceSpaces(self.output)433 self.assertEqualDiff(expected, output)434 expected += \435 "hier/foo 1.0-0 ---\n" \436 "hier/foo (test2) 1.0-0 ---\n"437 expected = self.reduceSpaces(expected)438 self.pkg("list -aH '*fo*'")439 output = self.reduceSpaces(self.output)440 self.assertEqualDiff(expected, output)441 for pat, ecode in (("foo food", 0), ("bogus", 1),442 ("foo bogus", 3), ("foo food bogus", 3),443 ("bogus quirky names", 1), ("'fo*' bogus", 3),444 ("'fo*' food bogus", 3), ("'f?o*' bogus", 3)):445 self.pkg("list -a {0}".format(pat), exit=ecode)446 self.pkg("list junk_pkg_name", exit=1)447 self.assertTrue("junk_pkg_name" in self.errout)448 def test_13_multi_name(self):449 """Test for multiple name match listing."""450 self.pkg("list -aHf '/foo*@1.2'")451 expected = \452 "foo 1.2.1-0 ---\n" + \453 "foo 1.2-0 ---\n" + \454 "foo (test2) 1.2.1-0 ---\n" + \455 "foo (test2) 1.2-0 ---\n" + \456 "food 1.2-0 ---\n" + \457 "food (test2) 1.2-0 ---\n"458 output = self.reduceSpaces(self.output)459 expected = self.reduceSpaces(expected)460 self.assertEqualDiff(expected, output)461 self.pkg("list -aH '/foo*@1.2'")462 expected = \463 "foo 1.2.1-0 ---\n" + \464 "foo (test2) 1.2.1-0 ---\n" + \465 "food 1.2-0 ---\n" + \466 "food (test2) 1.2-0 ---\n"467 output = self.reduceSpaces(self.output)468 expected = self.reduceSpaces(expected)469 self.assertEqualDiff(expected, output)470 def test_14_invalid_input(self):471 """Verify that invalid input is handled gracefully."""472 pats = ("bar -v", "*@a", "bar@a", "@1.0", "foo@1.0.a")473 # First, test individually.474 for val in pats:475 self.pkg("list {0}".format(val), exit=1)476 self.assertTrue(self.errout)477 # Next, test invalid input but with options. The option478 # should not be in the error output. (If it is, the FMRI479 # parsing has parsed the option too.)480 self.pkg("list -a bar@a", exit=1)481 self.assertTrue(self.output.find("FMRI '-a'") == -1)482 # Should only print fatal errors when using -q.483 self.pkg("list -aq bar@a", exit=1)484 self.__check_qoutput(errout=True)485 # Last, test all at once.486 self.pkg("list {0}".format(" ".join(pats)), exit=1)487 def test_15_latest(self):488 """Verify that FMRIs using @latest work as expected and489 that -n provides the same results."""490 self.pkg("list -aHf foo@latest")491 expected = \492 "foo 1.2.1-0 ---\n" \493 "foo (test2) 1.2.1-0 ---\n" \494 "hier/foo 1.0-0 ---\n" \495 "hier/foo (test2) 1.0-0 ---\n"496 output = self.reduceSpaces(self.output)497 expected = self.reduceSpaces(expected)498 self.assertEqualDiff(expected, output)499 self.pkg("list -Hn foo")500 output = self.reduceSpaces(self.output)501 expected = self.reduceSpaces(expected)502 self.assertEqualDiff(expected, output)503 self.pkg("list -aHf foo@latest foo@1.1 //test2/foo@1.2")504 expected = \505 "foo 1.2.1-0 ---\n" \506 "foo 1.1-0 ---\n" \507 "foo (test2) 1.2.1-0 ---\n" \508 "foo (test2) 1.2-0 ---\n" \509 "foo (test2) 1.1-0 ---\n" \510 "hier/foo 1.0-0 ---\n" \511 "hier/foo (test2) 1.0-0 ---\n"512 output = self.reduceSpaces(self.output)513 expected = self.reduceSpaces(expected)514 self.assertEqualDiff(expected, output)515 self.pkg("list -aHf /hier/foo@latest //test1/foo@latest")516 expected = \517 "foo 1.2.1-0 ---\n" \518 "hier/foo 1.0-0 ---\n" \519 "hier/foo (test2) 1.0-0 ---\n"520 output = self.reduceSpaces(self.output)521 expected = self.reduceSpaces(expected)522 self.assertEqualDiff(expected, output)523 self.pkg("list -Hn /hier/foo //test1/foo")524 output = self.reduceSpaces(self.output)525 expected = self.reduceSpaces(expected)526 self.assertEqualDiff(expected, output)527 def test_16_upgradable(self):528 """Verify that pkg list -u works as expected."""529 self.image_create(self.rurl1)530 self.pkg("install /foo@1.0")531 # 'foo' should be listed since 1.2.1 is available.532 self.pkg("list -H")533 expected = \534 "foo 1.0-0 i--\n"535 output = self.reduceSpaces(self.output)536 expected = self.reduceSpaces(expected)537 self.assertEqualDiff(expected, output)538 # 'foo' should be listed since 1.2.1 is available.539 self.pkg("list -Hu foo")540 output = self.reduceSpaces(self.output)541 expected = self.reduceSpaces(expected)542 self.assertEqualDiff(expected, output)543 # Should not print anything if using -q.544 self.pkg("list -Hqu foo")545 self.__check_qoutput(errout=False)546 # Upgrade foo.547 self.pkg("update foo")548 # Should return error as newest version is now installed.549 self.pkg("list -Hu foo", exit=1)550 self.assertEqualDiff(self.output, "")551 self.assertTrue(self.errout != "")552 # Should not print anything if using -q.553 self.pkg("list -Hqu foo", exit=1)554 self.__check_qoutput(errout=False)555 def test_17_verbose(self):556 """Verify that pkg list -v works as expected."""557 # FMRI with no branch component should be displayed correctly.558 plist = self.pkgsend_bulk(self.rurl1, self.newpkg10)559 self.pkg("install newpkg@1.0")560 self.pkg("list -Hv newpkg")561 output = self.reduceSpaces(self.output)562 expected = fmri.PkgFmri(plist[0]).get_fmri(563 include_build=False) + " i--\n"564 self.assertEqualDiff(expected, output)565class TestPkgListSingle(pkg5unittest.SingleDepotTestCase):566 # Destroy test space every time.567 persistent_setup = False568 foo10 = """569 open foo@1.0,5.11-0570 close """571 unsupp10 = """572 open unsupported@1.0573 add depend type=require fmri=foo@1.0574 close """575 def __check_qoutput(self, errout=False):576 self.assertEqualDiff(self.output, "")577 if errout:578 self.assertTrue(self.errout != "",579 "-q must print fatal errors!")580 else:581 self.assertTrue(self.errout == "",582 "-q should only print fatal errors!")583 def test_01_empty_image(self):584 """ pkg list should fail in an empty image """585 self.image_create(self.rurl)586 self.pkg("list", exit=1)587 self.assertTrue(self.errout)588 # Should not print anything if using -q.589 self.pkg("list -q", exit=1)590 self.__check_qoutput(errout=False)591 def __populate_repo(self, unsupp_content):592 # Publish a package and then add some unsupported action data593 # to the repository's copy of the manifest and catalog.594 sfmri = self.pkgsend_bulk(self.rurl, self.unsupp10)[0]595 pfmri = fmri.PkgFmri(sfmri)596 repo = self.get_repo(self.dcs[1].get_repodir())597 mpath = repo.manifest(pfmri)598 with open(mpath, "a+") as mfile:599 mfile.write(unsupp_content + "\n")600 mcontent = None601 with open(mpath, "r") as mfile:602 mcontent = mfile.read()603 cat = repo.get_catalog("test")604 cat.log_updates = False605 # Update the catalog signature.606 entry = cat.get_entry(pfmri)607 entry["signature-sha-1"] = manifest.Manifest.hash_create(608 mcontent)609 # Update the catalog actions.610 self.debug(str(cat.parts))611 dpart = cat.get_part("catalog.dependency.C", must_exist=True)612 entry = dpart.get_entry(pfmri)613 entry["actions"].append(unsupp_content)614 # Write out the new catalog.615 cat.save()616 def test_02_unsupported(self):617 """Verify that packages with invalid or unsupported actions are618 handled gracefully.619 """620 # Base package needed for testing.621 self.pkgsend_bulk(self.rurl, self.foo10)622 # Verify that a package with unsupported content doesn't cause623 # a problem.624 newact = "depend type=new-type fmri=foo@1.1"625 # Now create a new image and verify that pkg list will626 # list both packages even though one of them has an627 # unparseable manifest.628 self.__populate_repo(newact)629 self.image_create(self.rurl)630 self.pkg("list -aH foo unsupported")631 expected = \632 "foo 1.0-0 ---\n" \633 "unsupported 1.0 ---\n"634 output = self.reduceSpaces(self.output)635 expected = self.reduceSpaces(expected)636 self.assertEqualDiff(expected, output)637 self.pkg("list -qaH foo unsupported")638 self.__check_qoutput(errout=False)639 # Verify that a package with invalid content doesn't cause640 # a problem.641 newact = "depend notvalid"642 self.__populate_repo(newact)643 self.pkg("refresh --full")644 self.pkg("list -afH foo unsupported")645 expected = \646 "foo 1.0-0 ---\n" \647 "unsupported 1.0 ---\n" \648 "unsupported 1.0 ---\n"649 output = self.reduceSpaces(self.output)650 expected = self.reduceSpaces(expected)651 self.assertEqualDiff(expected, output)652 self.pkg("list -afqH foo unsupported")653 self.__check_qoutput(errout=False)654if __name__ == "__main__":...
codegen-temporaries.js
Source:codegen-temporaries.js
...41 a.test = "PASS";42 return testObject.test;43}44shouldBe("assign_test1()", "'PASS'");45function assign_test2()46{47 var testObject = new TestObject;48 var a = testObject;49 a = a.test = "PASS";50 return testObject.test;51}52shouldBe("assign_test2()", "'PASS'");53function assign_test3()54{55 var testObject = new TestObject;56 var a = testObject;57 a.test = a = "PASS";58 return testObject.test;59}60shouldBe("assign_test3()", "'PASS'");61var testObject4 = new TestObject;62var a4 = testObject4;63a4.test = this.a4 = "PASS";64shouldBe("testObject4.test", "'PASS'");65var testObject5 = new TestObject;66var a5 = testObject5;67a5 = this.a5.test = "PASS";68shouldBe("testObject5.test", "'PASS'");69function assign_test6()70{71 var testObject = new TestObject;72 var a = testObject;73 a["test"] = "PASS";74 return testObject.test;75}76shouldBe("assign_test6()", "'PASS'");77function assign_test7()78{79 var testObject = new TestObject;80 var a = testObject;81 a = a["test"] = "PASS";82 return testObject.test;83}84shouldBe("assign_test7()", "'PASS'");85function assign_test8()86{87 var testObject = new TestObject;88 var a = testObject;89 a["test"] = a = "PASS";90 return testObject.test;91}92shouldBe("assign_test8()", "'PASS'");93function assign_test9()94{95 var testObject = new TestObject;96 var a = testObject;97 a["test"] = this.a = "PASS";98 return testObject.test;99}100shouldBe("assign_test9()", "'PASS'");101var testObject10 = new TestObject;102var a10 = testObject10;103a10 = this.a10["test"] = "PASS";104shouldBe("testObject10.test", "'PASS'");105function assign_test11()106{107 var testObject = new TestObject;108 var a = testObject;109 a[a = "test"] = "PASS";110 return testObject.test;111}112shouldBe("assign_test11()", "'PASS'");113function assign_test12()114{115 var test = "test";116 var testObject = new TestObject;117 var a = testObject;118 a[test] = "PASS";119 return testObject.test;120}121shouldBe("assign_test12()", "'PASS'");122function assign_test13()123{124 var testObject = new TestObject;125 var a = testObject;126 a.test = (a = "FAIL", "PASS");127 return testObject.test;128}129shouldBe("assign_test13()", "'PASS'");130function assign_test14()131{132 var testObject = new TestObject;133 var a = testObject;134 a["test"] = (a = "FAIL", "PASS");135 return testObject.test;136}137shouldBe("assign_test14()", "'PASS'");138function assign_test15()139{140 var test = "test";141 var testObject = new TestObject;142 var a = testObject;143 a[test] = (test = "FAIL", "PASS");144 return testObject.test;145}146shouldBe("assign_test15()", "'PASS'");147function assign_test16()148{149 var a = 1;150 a = (a = 2);151 return a;152}153shouldBe("assign_test16()", "2");154var a17 = 1;155a17 += (a17 += 1);156shouldBe("a17", "3");157function assign_test18()158{159 var a = 1;160 a += (a += 1);161 return a;162}163shouldBe("assign_test18()", "3");164var a19 = { b: 1 };165a19.b += (a19.b += 1);166shouldBe("a19.b", "3");167function assign_test20()168{169 var a = { b: 1 };170 a.b += (a.b += 1);171 return a.b;172}173shouldBe("assign_test20()", "3");174var a21 = { b: 1 };175a21["b"] += (a21["b"] += 1);176shouldBe("a21['b']", "3");177function assign_test22()178{179 var a = { b: 1 };180 a["b"] += (a["b"] += 1);181 return a["b"];182}183shouldBe("assign_test22()", "3");184function assign_test23()185{186 var o = { b: 1 };187 var a = o;188 a.b += a = 2;189 return o.b;190}191shouldBe("assign_test23()", "3");192function assign_test24()193{194 var o = { b: 1 };195 var a = o;196 a["b"] += a = 2;197 return o["b"];198}199shouldBe("assign_test24()", "3");200function assign_test25()201{202 var o = { b: 1 };203 var a = o;204 a[a = "b"] += a = 2;205 return o["b"];206}207shouldBe("assign_test25()", "3");208function assign_test26()209{210 var o = { b: 1 };211 var a = o;212 var b = "b";213 a[b] += a = 2;214 return o["b"];215}216shouldBe("assign_test26()", "3");217function assign_test27()218{219 var o = { b: 1 };220 var a = o;221 a.b += (a = 100, 2);222 return o.b;223}224shouldBe("assign_test27()", "3");225function assign_test28()226{227 var o = { b: 1 };228 var a = o;229 a["b"] += (a = 100, 2);230 return o["b"];231}232shouldBe("assign_test28()", "3");233function assign_test29()234{235 var o = { b: 1 };236 var a = o;237 var b = "b";238 a[b] += (a = 100, 2);239 return o["b"];240}241shouldBe("assign_test29()", "3");242function assign_test30()243{244 var a = "foo";245 a += (a++);246 return a;247}248shouldBe("assign_test30()", "'fooNaN'");249function assign_test31()250{251 function result() { return "PASS"; }252 return (globalVar = result)()253}254shouldBe("assign_test31()", "'PASS'");255function bracket_test1()256{257 var o = [-1];258 var a = o[++o];259 return a;260}261shouldBe("bracket_test1()", "-1");262function bracket_test2()263{264 var o = [1];265 var a = o[--o];266 return a;267}268shouldBe("bracket_test2()", "1");269function bracket_test3()270{271 var o = [0];272 var a = o[o++];273 return a;274}275shouldBe("bracket_test3()", "0");276function bracket_test4()277{278 var o = [0];279 var a = o[o--];280 return a;281}282shouldBe("bracket_test4()", "0");283function bracket_test5()284{285 var o = [1];286 var a = o[o ^= 1];287 return a;288}289shouldBe("bracket_test5()", "1");290function bracket_test6()291{292 var o = { b: 1 }293 var b = o[o = { b: 2 }, "b"];294 return b;295}296shouldBe("bracket_test6()", "1");297function mult_test1()298{299 var a = 1;300 return a * (a = 2);301}302shouldBe("mult_test1()", "2");303function mult_test2()304{305 var a = 1;306 return a * ++a;307}308shouldBe("mult_test2()", "2");309function mult_test3()310{311 var a = 1;312 return a * (a += 1);313}314shouldBe("mult_test3()", "2");315function div_test1()316{317 var a = 1;318 return a / (a = 2);319}320shouldBe("div_test1()", "0.5");321function div_test2()322{323 var a = 1;324 return a / ++a;325}326shouldBe("div_test2()", "0.5");327function div_test3()328{329 var a = 1;330 return a / (a += 1);331}332shouldBe("div_test3()", "0.5");333function mod_test1()334{335 var a = 1;336 return a % (a = 2);337}338shouldBe("mod_test1()", "1");339function mod_test2()340{341 var a = 1;342 return a % ++a;343}344shouldBe("mod_test2()", "1");345function mod_test3()346{347 var a = 1;348 return a % (a += 1);349}350shouldBe("mod_test3()", "1");351function add_test1()352{353 var a = 1;354 return a + (a = 2);355}356shouldBe("add_test1()", "3");357function add_test2()358{359 var a = 1;360 return a + ++a;361}362shouldBe("add_test2()", "3");363function add_test3()364{365 var a = 1;366 return a + (a += 1);367}368shouldBe("add_test3()", "3");369function sub_test1()370{371 var a = 1;372 return a - (a = 2);373}374shouldBe("sub_test1()", "-1");375function sub_test2()376{377 var a = 1;378 return a - ++a;379}380shouldBe("sub_test2()", "-1");381function sub_test3()382{383 var a = 1;384 return a - (a += 1);385}386shouldBe("sub_test3()", "-1");387function lshift_test1()388{389 var a = 1;390 return a << (a = 2);391}392shouldBe("lshift_test1()", "4");393function lshift_test2()394{395 var a = 1;396 return a << ++a;397}398shouldBe("lshift_test2()", "4");399function lshift_test3()400{401 var a = 1;402 return a << (a += 1);403}404shouldBe("lshift_test3()", "4");405function rshift_test1()406{407 var a = 4;408 return a >> (a = 2);409}410shouldBe("rshift_test1()", "1");411function rshift_test2()412{413 var a = 2;414 return a >> --a;415}416shouldBe("rshift_test2()", "1");417function rshift_test3()418{419 var a = 2;420 return a >> (a -= 1);421}422shouldBe("rshift_test3()", "1");423function urshift_test1()424{425 var a = 4;426 return a >>> (a = 2);427}428shouldBe("urshift_test1()", "1");429function urshift_test2()430{431 var a = 2;432 return a >>> --a;433}434shouldBe("urshift_test2()", "1");435function urshift_test3()436{437 var a = 2;438 return a >>> (a -= 1);439}440shouldBe("urshift_test3()", "1");441function less_test1()442{443 var a = 1;444 return a < (a = 2);445}446shouldBeTrue("less_test1()");447function less_test2()448{449 var a = 1;450 return a < ++a;451}452shouldBeTrue("less_test2()");453function less_test3()454{455 var a = 1;456 return a < (a += 1);457}458shouldBeTrue("less_test3()");459function greater_test1()460{461 var a = 2;462 return a > (a = 1);463}464shouldBeTrue("greater_test1()");465function greater_test2()466{467 var a = 2;468 return a > --a;469}470shouldBeTrue("greater_test2()");471function greater_test3()472{473 var a = 2;474 return a > (a -= 1);475}476shouldBeTrue("greater_test3()");477function lesseq_test1()478{479 var a = 1;480 return a <= (a = 3, 2);481}482shouldBeTrue("lesseq_test1()");483function lesseq_test2()484{485 var a = 1;486 return a <= (++a, 1);487}488shouldBeTrue("lesseq_test2()");489function lesseq_test3()490{491 var a = 1;492 return a <= (a += 1, 1);493}494shouldBeTrue("lesseq_test3()");495function greatereq_test1()496{497 var a = 2;498 return a >= (a = 1, 2);499}500shouldBeTrue("greatereq_test1()");501function greatereq_test2()502{503 var a = 2;504 return a >= (--a, 2);505}506shouldBeTrue("greatereq_test2()");507function greatereq_test3()508{509 var a = 2;510 return a >= (a -= 1, 2);511}512shouldBeTrue("greatereq_test3()");513function instanceof_test1()514{515 var a = { };516 return a instanceof (a = 1, Object);517}518shouldBeTrue("instanceof_test1()");519function instanceof_test2()520{521 var a = { valueOf: function() { return 1; } };522 return a instanceof (++a, Object);523}524shouldBeTrue("instanceof_test2()");525function instanceof_test3()526{527 var a = { valueOf: function() { return 1; } };528 return a instanceof (a += 1, Object);529}530shouldBeTrue("instanceof_test3()");531function in_test1()532{533 var a = "a";534 return a in (a = "b", { a: 1 });535}536shouldBeTrue("in_test1()");537function in_test2()538{539 var a = { toString: function() { return "a"; }, valueOf: function() { return 1; } };540 return a in (++a, { a: 1 });541}542shouldBeTrue("in_test2()");543function in_test3()544{545 var a = { toString: function() { return "a"; }, valueOf: function() { return 1; } };546 return a in (a += 1, { a: 1 });547}548shouldBeTrue("in_test3()");549function eq_test1()550{551 var a = 1;552 return a == (a = 2);553}554shouldBeFalse("eq_test1()");555function eq_test2()556{557 var a = 1;558 return a == ++a;559}560shouldBeFalse("eq_test2()");561function eq_test3()562{563 var a = 1;564 return a == (a += 1);565}566shouldBeFalse("eq_test3()");567function neq_test1()568{569 var a = 1;570 return a != (a = 2);571}572shouldBeTrue("neq_test1()");573function neq_test2()574{575 var a = 1;576 return a != ++a;577}578shouldBeTrue("neq_test2()");579function neq_test3()580{581 var a = 1;582 return a != (a += 1);583}584shouldBeTrue("neq_test3()");585function stricteq_test1()586{587 var a = 1;588 return a === (a = 2);589}590shouldBeFalse("stricteq_test1()");591function stricteq_test2()592{593 var a = 1;594 return a === ++a;595}596shouldBeFalse("stricteq_test2()");597function stricteq_test3()598{599 var a = 1;600 return a === (a += 1);601}602shouldBeFalse("stricteq_test3()");603function nstricteq_test1()604{605 var a = 1;606 return a !== (a = 2);607}608shouldBeTrue("nstricteq_test1()");609function nstricteq_test2()610{611 var a = 1;612 return a !== ++a;613}614shouldBeTrue("nstricteq_test2()");615function nstricteq_test3()616{617 var a = 1;618 return a !== (a += 1);619}620shouldBeTrue("nstricteq_test3()");621function bitand_test1()622{623 var a = 1;624 return a & (a = 2);625}626shouldBe("bitand_test1()", "0");627function bitand_test2()628{629 var a = 1;630 return a & ++a;631}632shouldBe("bitand_test2()", "0");633function bitand_test3()634{635 var a = 1;636 return a & (a += 1);637}638shouldBe("bitand_test3()", "0");639function bitor_test1()640{641 var a = 1;642 return a | (a = 2);643}644shouldBe("bitor_test1()", "3");645function bitor_test2()646{647 var a = 1;648 return a | ++a;649}650shouldBe("bitor_test2()", "3");651function bitor_test3()652{653 var a = 1;654 return a | (a += 1);655}656shouldBe("bitor_test3()", "3");657function bitxor_test1()658{659 var a = 1;660 return a ^ (a = 2);661}662shouldBe("bitxor_test1()", "3");663function bitxor_test2()664{665 var a = 1;666 return a ^ ++a;667}668shouldBe("bitxor_test2()", "3");669function bitxor_test3()670{671 var a = 1;672 return a ^ (a += 1);673}674shouldBe("bitxor_test3()", "3");675function switch_test1_helper(a, b)676{677 switch (a) {678 case b:679 break;680 default:681 break;682 }683 return b;684}685function switch_test1()686{687 return switch_test1_helper(0, 1) == 1;688}689shouldBeTrue("switch_test1()");690function switch_test2_helper(a, b)691{692 var c = b;693 switch (a) {694 case c:695 break;696 default:697 break;698 }699 return c;700}701function switch_test2()702{703 return switch_test2_helper(0, 1) == 1;704}705shouldBeTrue("switch_test2()");706function switch_test3_helper(a)707{708 switch (a) {709 case this:710 break;711 default:712 break;713 }714 return this;715}716function switch_test3()717{718 return this == switch_test3_helper.call(this, 0);719}...
numbered-header-element.js
Source:numbered-header-element.js
1// Test for WebKit Bug 15136 - HTML5 spec violation: </h1> doesn't end <h3> element in Webkit2// https://bugs.webkit.org/show_bug.cgi?id=151363// rdar://problem/57628824description('Test that any numbered header element end tag can close any other open numbered header element.');5var testParent = document.createElement('div');6testParent.id = 'test0';7document.body.appendChild(testParent);8// h19debug('<h1> closes <h1>:');10testParent.innerHTML = '<h1 id="test1"></h1><div id="test2"></div><p>Test that <h1> closes <h1.</p>';11var h1 = document.getElementById('test2');12shouldBeFalse('test2.parentNode.id == "test1"');13shouldBeTrue('test2.parentNode.id == "test0"');14debug('<h2> closes <h1>:');15testParent.innerHTML = '<h1 id="test1"></h2><div id="test2"></div><p>Test that <h2> closes <h1.</p>';16var h1 = document.getElementById('test2');17shouldBeFalse('test2.parentNode.id == "test1"');18shouldBeTrue('test2.parentNode.id == "test0"');19debug('<h3> closes <h1>:');20testParent.innerHTML = '<h1 id="test1"></h3><div id="test2"></div><p>Test that <h3> closes <h1.</p>';21var h1 = document.getElementById('test2');22shouldBeFalse('test2.parentNode.id == "test1"');23shouldBeTrue('test2.parentNode.id == "test0"');24debug('<h4> closes <h1>:');25testParent.innerHTML = '<h1 id="test1"></h4><div id="test2"></div><p>Test that <h4> closes <h1.</p>';26var h1 = document.getElementById('test2');27shouldBeFalse('test2.parentNode.id == "test1"');28shouldBeTrue('test2.parentNode.id == "test0"');29debug('<h5> closes <h1>:');30testParent.innerHTML = '<h1 id="test1"></h5><div id="test2"></div><p>Test that <h5> closes <h1.</p>';31var h1 = document.getElementById('test2');32shouldBeFalse('test2.parentNode.id == "test1"');33shouldBeTrue('test2.parentNode.id == "test0"');34debug('<h6> closes <h1>:');35testParent.innerHTML = '<h1 id="test1"></h6><div id="test2"></div><p>Test that <h6> closes <h1.</p>';36var h1 = document.getElementById('test2');37shouldBeFalse('test2.parentNode.id == "test1"');38shouldBeTrue('test2.parentNode.id == "test0"');39// h240debug('<h1> closes <h2>:');41testParent.innerHTML = '<h2 id="test1"></h1><div id="test2"></div><p>Test that <h1> closes <h2.</p>';42var h1 = document.getElementById('test2');43shouldBeFalse('test2.parentNode.id == "test1"');44shouldBeTrue('test2.parentNode.id == "test0"');45debug('<h2> closes <h2>:');46testParent.innerHTML = '<h2 id="test1"></h2><div id="test2"></div><p>Test that <h2> closes <h2.</p>';47var h1 = document.getElementById('test2');48shouldBeFalse('test2.parentNode.id == "test1"');49shouldBeTrue('test2.parentNode.id == "test0"');50debug('<h3> closes <h2>:');51testParent.innerHTML = '<h2 id="test1"></h3><div id="test2"></div><p>Test that <h3> closes <h2.</p>';52var h1 = document.getElementById('test2');53shouldBeFalse('test2.parentNode.id == "test1"');54shouldBeTrue('test2.parentNode.id == "test0"');55debug('<h4> closes <h2>:');56testParent.innerHTML = '<h2 id="test1"></h4><div id="test2"></div><p>Test that <h4> closes <h2.</p>';57var h1 = document.getElementById('test2');58shouldBeFalse('test2.parentNode.id == "test1"');59shouldBeTrue('test2.parentNode.id == "test0"');60debug('<h5> closes <h2>:');61testParent.innerHTML = '<h2 id="test1"></h5><div id="test2"></div><p>Test that <h5> closes <h2.</p>';62var h1 = document.getElementById('test2');63shouldBeFalse('test2.parentNode.id == "test1"');64shouldBeTrue('test2.parentNode.id == "test0"');65debug('<h6> closes <h2>:');66testParent.innerHTML = '<h2 id="test1"></h6><div id="test2"></div><p>Test that <h6> closes <h2.</p>';67var h1 = document.getElementById('test2');68shouldBeFalse('test2.parentNode.id == "test1"');69shouldBeTrue('test2.parentNode.id == "test0"');70// h371debug('<h1> closes <h3>:');72testParent.innerHTML = '<h3 id="test1"></h1><div id="test2"></div><p>Test that <h1> closes <h3.</p>';73var h1 = document.getElementById('test2');74shouldBeFalse('test2.parentNode.id == "test1"');75shouldBeTrue('test2.parentNode.id == "test0"');76debug('<h2> closes <h3>:');77testParent.innerHTML = '<h3 id="test1"></h2><div id="test2"></div><p>Test that <h2> closes <h3.</p>';78var h1 = document.getElementById('test2');79shouldBeFalse('test2.parentNode.id == "test1"');80shouldBeTrue('test2.parentNode.id == "test0"');81debug('<h3> closes <h3>:');82testParent.innerHTML = '<h3 id="test1"></h3><div id="test2"></div><p>Test that <h3> closes <h3.</p>';83var h1 = document.getElementById('test2');84shouldBeFalse('test2.parentNode.id == "test1"');85shouldBeTrue('test2.parentNode.id == "test0"');86debug('<h4> closes <h3>:');87testParent.innerHTML = '<h3 id="test1"></h4><div id="test2"></div><p>Test that <h4> closes <h3.</p>';88var h1 = document.getElementById('test2');89shouldBeFalse('test2.parentNode.id == "test1"');90shouldBeTrue('test2.parentNode.id == "test0"');91debug('<h5> closes <h3>:');92testParent.innerHTML = '<h3 id="test1"></h5><div id="test2"></div><p>Test that <h5> closes <h3.</p>';93var h1 = document.getElementById('test2');94shouldBeFalse('test2.parentNode.id == "test1"');95shouldBeTrue('test2.parentNode.id == "test0"');96debug('<h6> closes <h3>:');97testParent.innerHTML = '<h3 id="test1"></h6><div id="test2"></div><p>Test that <h6> closes <h3.</p>';98var h1 = document.getElementById('test2');99shouldBeFalse('test2.parentNode.id == "test1"');100shouldBeTrue('test2.parentNode.id == "test0"');101// h4102debug('<h1> closes <h4>:');103testParent.innerHTML = '<h4 id="test1"></h1><div id="test2"></div><p>Test that <h1> closes <h4.</p>';104var h1 = document.getElementById('test2');105shouldBeFalse('test2.parentNode.id == "test1"');106shouldBeTrue('test2.parentNode.id == "test0"');107debug('<h2> closes <h4>:');108testParent.innerHTML = '<h4 id="test1"></h2><div id="test2"></div><p>Test that <h2> closes <h4.</p>';109var h1 = document.getElementById('test2');110shouldBeFalse('test2.parentNode.id == "test1"');111shouldBeTrue('test2.parentNode.id == "test0"');112debug('<h3> closes <h4>:');113testParent.innerHTML = '<h4 id="test1"></h3><div id="test2"></div><p>Test that <h3> closes <h4.</p>';114var h1 = document.getElementById('test2');115shouldBeFalse('test2.parentNode.id == "test1"');116shouldBeTrue('test2.parentNode.id == "test0"');117debug('<h4> closes <h4>:');118testParent.innerHTML = '<h4 id="test1"></h4><div id="test2"></div><p>Test that <h4> closes <h4.</p>';119var h1 = document.getElementById('test2');120shouldBeFalse('test2.parentNode.id == "test1"');121shouldBeTrue('test2.parentNode.id == "test0"');122debug('<h5> closes <h4>:');123testParent.innerHTML = '<h4 id="test1"></h5><div id="test2"></div><p>Test that <h5> closes <h4.</p>';124var h1 = document.getElementById('test2');125shouldBeFalse('test2.parentNode.id == "test1"');126shouldBeTrue('test2.parentNode.id == "test0"');127debug('<h6> closes <h4>:');128testParent.innerHTML = '<h4 id="test1"></h6><div id="test2"></div><p>Test that <h6> closes <h4.</p>';129var h1 = document.getElementById('test2');130shouldBeFalse('test2.parentNode.id == "test1"');131shouldBeTrue('test2.parentNode.id == "test0"');132// h5133debug('<h1> closes <h5>:');134testParent.innerHTML = '<h5 id="test1"></h1><div id="test2"></div><p>Test that <h1> closes <h5.</p>';135var h1 = document.getElementById('test2');136shouldBeFalse('test2.parentNode.id == "test1"');137shouldBeTrue('test2.parentNode.id == "test0"');138debug('<h2> closes <h5>:');139testParent.innerHTML = '<h5 id="test1"></h2><div id="test2"></div><p>Test that <h2> closes <h5.</p>';140var h1 = document.getElementById('test2');141shouldBeFalse('test2.parentNode.id == "test1"');142shouldBeTrue('test2.parentNode.id == "test0"');143debug('<h3> closes <h5>:');144testParent.innerHTML = '<h5 id="test1"></h3><div id="test2"></div><p>Test that <h3> closes <h5.</p>';145var h1 = document.getElementById('test2');146shouldBeFalse('test2.parentNode.id == "test1"');147shouldBeTrue('test2.parentNode.id == "test0"');148debug('<h4> closes <h5>:');149testParent.innerHTML = '<h5 id="test1"></h4><div id="test2"></div><p>Test that <h4> closes <h5.</p>';150var h1 = document.getElementById('test2');151shouldBeFalse('test2.parentNode.id == "test1"');152shouldBeTrue('test2.parentNode.id == "test0"');153debug('<h5> closes <h5>:');154testParent.innerHTML = '<h5 id="test1"></h5><div id="test2"></div><p>Test that <h5> closes <h5.</p>';155var h1 = document.getElementById('test2');156shouldBeFalse('test2.parentNode.id == "test1"');157shouldBeTrue('test2.parentNode.id == "test0"');158debug('<h6> closes <h5>:');159testParent.innerHTML = '<h5 id="test1"></h6><div id="test2"></div><p>Test that <h6> closes <h5.</p>';160var h1 = document.getElementById('test2');161shouldBeFalse('test2.parentNode.id == "test1"');162shouldBeTrue('test2.parentNode.id == "test0"');163// h6164debug('<h1> closes <h6>:');165testParent.innerHTML = '<h6 id="test1"></h1><div id="test2"></div><p>Test that <h1> closes <h6.</p>';166var h1 = document.getElementById('test2');167shouldBeFalse('test2.parentNode.id == "test1"');168shouldBeTrue('test2.parentNode.id == "test0"');169debug('<h2> closes <h6>:');170testParent.innerHTML = '<h6 id="test1"></h2><div id="test2"></div><p>Test that <h2> closes <h6.</p>';171var h1 = document.getElementById('test2');172shouldBeFalse('test2.parentNode.id == "test1"');173shouldBeTrue('test2.parentNode.id == "test0"');174debug('<h3> closes <h6>:');175testParent.innerHTML = '<h6 id="test1"></h3><div id="test2"></div><p>Test that <h3> closes <h6.</p>';176var h1 = document.getElementById('test2');177shouldBeFalse('test2.parentNode.id == "test1"');178shouldBeTrue('test2.parentNode.id == "test0"');179debug('<h4> closes <h6>:');180testParent.innerHTML = '<h6 id="test1"></h4><div id="test2"></div><p>Test that <h4> closes <h6.</p>';181var h1 = document.getElementById('test2');182shouldBeFalse('test2.parentNode.id == "test1"');183shouldBeTrue('test2.parentNode.id == "test0"');184debug('<h5> closes <h6>:');185testParent.innerHTML = '<h6 id="test1"></h5><div id="test2"></div><p>Test that <h5> closes <h6.</p>';186var h1 = document.getElementById('test2');187shouldBeFalse('test2.parentNode.id == "test1"');188shouldBeTrue('test2.parentNode.id == "test0"');189debug('<h6> closes <h6>:');190testParent.innerHTML = '<h6 id="test1"></h6><div id="test2"></div><p>Test that <h6> closes <h6.</p>';191var h1 = document.getElementById('test2');192shouldBeFalse('test2.parentNode.id == "test1"');193shouldBeTrue('test2.parentNode.id == "test0"');...
uniterrorcharsets.py
Source:uniterrorcharsets.py
1#!/usr/bin/env python2import sys3import bots.botslib as botslib4import bots.botsglobal as botsglobal5import bots.botsinit as botsinit6'''7no plugin needed.8run in commandline.9should give no errors.10utf-16 etc are reported.11'''12def testraise(expect,msg2,*args,**kwargs):13 try:14 raise botslib.BotsError(msg2,*args,**kwargs)15 except Exception, msg:16 if not isinstance(msg,unicode):17 msg = unicode(msg)18 #~ print 'not unicode',type(msg),expect19 #~ print 'Error xxx\n',msg20 if expect:21 if unicode(expect) != msg.strip():22 print expect,'(expected)'23 print msg,'(received)'24 txt = botslib.txtexc()25 if not isinstance(txt,unicode):26 print 'Error txt\n',txt27 28# .decode(): bytes->unicode29# .encode(): unicode -> bytes30def testrun():31 print '\n'32 #normal, valid handling33 testraise('','',{'test1':'test1','test2':'test2','test3':'test3'})34 testraise('0test','0test',{'test1':'test1','test2':'test2','test3':'test3'})35 testraise('0test test1 test2','0test %(test1)s %(test2)s %(test4)s',{'test1':'test1','test2':'test2','test3':'test3'})36 testraise('1test test1 test2 test3','1test %(test1)s %(test2)s %(test3)s',{'test1':'test1','test2':'test2','test3':'test3'})37 testraise(u'2test test1 test2 test3',u'2test %(test1)s %(test2)s %(test3)s',{u'test1':u'test1',u'test2':u'test2',u'test3':u'test3'})38 #different inputs in BotsError39 testraise(u'3test','3test')40 testraise(u'4test test1 test2',u'4test %(test1)s %(test2)s %(test3)s',{u'test1':u'test1',u'test2':u'test2'})41 testraise(u'5test test1 test2',u'5test %(test1)s %(test2)s %(test3)s',test1=u'test1',test2=u'test2')42 testraise(u'6test',u'6test %(test1)s %(test2)s %(test3)s',u'test1')43 testraise(u"7test [u'test1', u'test2']",u'7test %(test1)s %(test2)s %(test3)s',test1=[u'test1',u'test2'])44 testraise(u"8test {u'test1': u'test1', u'test2': u'test2'}",u'8test %(test1)s %(test2)s %(test3)s',test1={u'test1':u'test1',u'test2':u'test2'})45 testraise(u"9test [<module 'bots.botslib' from '/home/hje/Bots/botsdev/bots/botslib.pyc'>, <module 'bots.botslib' from '/home/hje/Bots/botsdev/bots/botslib.pyc'>]",46 u'9test %(test1)s %(test2)s %(test3)s',test1=[botslib,botslib])47 #different charsets in BotsError48 testraise(u'12test test1 test2 test3',u'12test %(test1)s %(test2)s %(test3)s',{u'test1':u'test1',u'test2':u'test2',u'test3':u'test3'})49 testraise(u'13test\u00E9\u00EB\u00FA\u00FB\u00FC\u0103\u0178\u01A1\u0202 test1\u00E9\u00EB\u00FA\u00FB\u00FC\u0103\u0178\u01A1\u0202 test2\u00E9\u00EB\u00FA\u00FB\u00FC\u0103\u0178\u01A1\u0202 test3\u00E9\u00EB\u00FA\u00FB\u00FC\u0103\u0178\u01A1\u0202',50 u'13test\u00E9\u00EB\u00FA\u00FB\u00FC\u0103\u0178\u01A1\u0202 %(test1)s %(test2)s %(test3)s',51 {u'test1':u'test1\u00E9\u00EB\u00FA\u00FB\u00FC\u0103\u0178\u01A1\u0202',u'test2':u'test2\u00E9\u00EB\u00FA\u00FB\u00FC\u0103\u0178\u01A1\u0202',u'test3':u'test3\u00E9\u00EB\u00FA\u00FB\u00FC\u0103\u0178\u01A1\u0202'})52 testraise(u'14test\u00E9\u00EB\u00FA\u00FB\u00FC\u0103\u0178\u01A1\u0202 test1\u00E9\u00EB\u00FA\u00FB\u00FC\u0103\u0178\u01A1\u0202',53 u'14test\u00E9\u00EB\u00FA\u00FB\u00FC\u0103\u0178\u01A1\u0202 %(test1)s'.encode('utf_8'),54 {u'test1':u'test1\u00E9\u00EB\u00FA\u00FB\u00FC\u0103\u0178\u01A1\u0202'.encode('utf_8')})55 testraise(u'15test test1',56 u'15test %(test1)s',57 {u'test1':u'test1'.encode('utf_16')})58 testraise(u'16test\u00E9\u00EB\u00FA\u00FB\u00FC\u0103\u0178\u01A1\u0202 test1\u00E9\u00EB\u00FA\u00FB\u00FC\u0103\u0178\u01A1\u0202',59 u'16test\u00E9\u00EB\u00FA\u00FB\u00FC\u0103\u0178\u01A1\u0202 %(test1)s',60 {u'test1':u'test1\u00E9\u00EB\u00FA\u00FB\u00FC\u0103\u0178\u01A1\u0202'.encode('utf_16')})61 testraise(u'17test\u00E9\u00EB\u00FA\u00FB\u00FC\u0103\u0178\u01A1\u0202 test1\u00E9\u00EB\u00FA\u00FB\u00FC\u0103\u0178\u01A1\u0202',62 u'17test\u00E9\u00EB\u00FA\u00FB\u00FC\u0103\u0178\u01A1\u0202 %(test1)s',63 {u'test1':u'test1\u00E9\u00EB\u00FA\u00FB\u00FC\u0103\u0178\u01A1\u0202'.encode('utf_32')})64 testraise(u'18test\u00E9\u00EB\u00FA\u00FB\u00FC test1\u00E9\u00EB\u00FA\u00FB\u00FC',65 u'18test\u00E9\u00EB\u00FA\u00FB\u00FC %(test1)s',66 {u'test1':u'test1\u00E9\u00EB\u00FA\u00FB\u00FC'.encode('latin_1')})67 testraise(u'19test test1',68 u'19test %(test1)s',69 {u'test1':u'test1'.encode('cp500')})70 testraise(u'20test test1',71 u'20test %(test1)s',72 {u'test1':u'test1'.encode('euc_jp')})73 #make utf-8 unicode string,many chars74 l = []75 for i in xrange(0,pow(256,2)):76 l.append(unichr(i))77 s = u''.join(l)78 print type(s)79 testraise(u'',s)80 #~ print type(s)81 s2 = s.encode('utf-8')82 print type(s2)83 testraise(u'',s2)84 85 #make iso-8859-1 string,many chars86 l = []87 for i in range(0,256):88 l.append(chr(i))89 s = ''.join(l)90 print type(s)91 #~ print s92 testraise(u'',s)93 s2 = s.decode('latin_1')94 print type(s2)95 testraise(u'',s2)96if __name__ == '__main__':97 botsinit.generalinit('config')98 botsinit.initbotscharsets()99 botsglobal.logger = botsinit.initenginelogging('engine')100 botsglobal.ini.set('settings','debug','False')101 testrun()102 botsglobal.ini.set('settings','debug','True')103 testrun()...
list_class.py
Source:list_class.py
1class List:2 def __init__(self, list_source):3 self.list0 = list_source4 def index(self, index0):5 return self.list0[index0]6 def cut(self, index1, index2):7 returns = []8 for i in range(index1, index2 + 1):9 returns.append(self.list0[i])10 return returns11 def __add__(self, other):12 result_list = self.list0[:]13 for element in other.list0:14 result_list.append(element)15 return List(result_list)16 def lenth(self):17 return len(self.list0)18 def maximum(self):19 max0 = self.list0[0]20 for element in self.list0:21 if element > max0:22 max0 = element23 return max024 def minimum(self):25 min0 = self.list0[0]26 for element in self.list0:27 if element < min0:28 min0 = element29 return min030 def delete(self, index0):31 self.list0 = self.list0[:index0] + self.list0[index0 + 1:]32 def append(self, element):33 self.list0 += [element]34 def extend(self, iter0):35 for i in iter0:36 self.append(i)37 def count(self, element):38 times = 039 for i in self.list0:40 if i == element:41 times += 142 return times43 def index_find(self, target, *index0):44 if len(index0) == 0:45 for i in range(self.lenth()):46 if self.list0[i] == target:47 return i48 return 'None'49 elif len(index0) == 1:50 for i in range(index0[0], self.lenth()):51 if self.list0[i] == target:52 return i53 return 'None'54 elif len(index0) == 2:55 for i in range(index0[0], index0[1]):56 if self.list0[i] == target:57 return i58 return 'None'59 def insert(self, index0, element):60 self.list0 = self.list0[:index0] + [element] + self.list0[index0:]61 def reserve(self):62 new_list = []63 for i in range(self.lenth()-1, -1, -1):64 new_list.append(self.list0[i])65 self.list0 = new_list66test0 = List([2, 45, 1, 3, 66, 9])67print(test0.list0)68print(test0.index(3))69print(test0.cut(2, 4))70test1 = List([99, 4])71test2 = test1 + test072print(test2.list0)73print(test2.lenth())74print(test2.maximum())75print(test2.minimum())76test2.delete(3)77print(test2.list0)78test2.append(45)79print(test2.list0)80list_extend = [1, 2, 3]81test2.extend(list_extend)82print(test2.list0)83print(test2.count(2))84print(test2.index_find(2, 3, 6))85test2.insert(3, 555)86print(test2.list0)87test2.reserve()...
disk_test.py
Source:disk_test.py
1# pylint: skip-file2try:3 from unittest.mock import patch4except ImportError:5 from mock import patch6import unittest7from blivet.devices import DiskDevice8from blivet.devicelibs import disk as disklib9from blivet.devicelibs import raid10from blivet.size import Size11class DiskDeviceRAIDPropertiesTestCase(unittest.TestCase):12 def test_disk_raid_properties(self):13 volumes = {"/dev/test1": disklib.LSMInfo("Test 1",14 ["/dev/test1"],15 raid.get_raid_level("raid0"),16 Size("512 KiB"),17 4),18 "/dev/test2": disklib.LSMInfo("Test 2",19 ["/dev/test2"],20 None,21 None,22 None)}23 test1 = DiskDevice("test1")24 test2 = DiskDevice("test2")25 test3 = DiskDevice("test3")26 # DiskDevice attributes should have the same values as the corresponding LSMInfo, or None27 with patch("blivet.devices.disk.disklib") as _disklib:28 _disklib.volumes = volumes29 test1_volume = volumes[test1.path]30 self.assertEqual(test1._volume, volumes[test1.path])31 self.assertEqual(test1.raid_system, test1_volume.system)32 self.assertEqual(test1.raid_level, test1_volume.raid_type)33 self.assertEqual(test1.raid_stripe_size, test1_volume.raid_stripe_size)34 self.assertEqual(test1.raid_disk_count, test1_volume.raid_disk_count)35 test2_volume = volumes[test2.path]36 self.assertEqual(test2._volume, volumes[test2.path])37 self.assertEqual(test2._volume, test2_volume)38 self.assertEqual(test2.raid_system, test2_volume.system)39 self.assertEqual(test2.raid_level, test2_volume.raid_type)40 self.assertEqual(test2.raid_stripe_size, test2_volume.raid_stripe_size)41 self.assertEqual(test2.raid_disk_count, test2_volume.raid_disk_count)42 self.assertIsNone(test3._volume)43 self.assertIsNone(test3.raid_system)44 self.assertIsNone(test3.raid_level)45 self.assertIsNone(test3.raid_stripe_size)...
gyptest-prune-targets.py
Source:gyptest-prune-targets.py
1#!/usr/bin/env python2# Copyright (c) 2013 Google Inc. All rights reserved.3# Use of this source code is governed by a BSD-style license that can be4# found in the LICENSE file.5"""6Verifies --root-target removes the unnecessary targets.7"""8import TestGyp9test = TestGyp.TestGyp()10# The xcode-ninja generator has its own logic for which targets to include11if test.format == 'xcode-ninja':12 test.skip_test()13build_error_code = {14 'cmake': 1,15 'make': 2,16 'msvs': 1,17 'ninja': 1,18 'xcode': 65,19}[test.format]20# By default, everything will be included.21test.run_gyp('test1.gyp')22test.build('test2.gyp', 'lib1')23test.build('test2.gyp', 'lib2')24test.build('test2.gyp', 'lib3')25test.build('test2.gyp', 'lib_indirect')26test.build('test1.gyp', 'program1')27test.build('test1.gyp', 'program2')28test.build('test1.gyp', 'program3')29# With deep dependencies of program1 only.30test.run_gyp('test1.gyp', '--root-target=program1')31test.build('test2.gyp', 'lib1')32test.build('test2.gyp', 'lib2', status=build_error_code, stderr=None)33test.build('test2.gyp', 'lib3', status=build_error_code, stderr=None)34test.build('test2.gyp', 'lib_indirect')35test.build('test1.gyp', 'program1')36test.build('test1.gyp', 'program2', status=build_error_code, stderr=None)37test.build('test1.gyp', 'program3', status=build_error_code, stderr=None)38# With deep dependencies of program2 only.39test.run_gyp('test1.gyp', '--root-target=program2')40test.build('test2.gyp', 'lib1', status=build_error_code, stderr=None)41test.build('test2.gyp', 'lib2')42test.build('test2.gyp', 'lib3', status=build_error_code, stderr=None)43test.build('test2.gyp', 'lib_indirect')44test.build('test1.gyp', 'program1', status=build_error_code, stderr=None)45test.build('test1.gyp', 'program2')46test.build('test1.gyp', 'program3', status=build_error_code, stderr=None)47# With deep dependencies of program1 and program2.48test.run_gyp('test1.gyp', '--root-target=program1', '--root-target=program2')49test.build('test2.gyp', 'lib1')50test.build('test2.gyp', 'lib2')51test.build('test2.gyp', 'lib3', status=build_error_code, stderr=None)52test.build('test2.gyp', 'lib_indirect')53test.build('test1.gyp', 'program1')54test.build('test1.gyp', 'program2')55test.build('test1.gyp', 'program3', status=build_error_code, stderr=None)...
SubscriptionFilterCli.py
Source:SubscriptionFilterCli.py
1az login2az account set --subscription "Your subscription"3# Add resource group4az group create --name FilterTest2 --location westus25# Add namespace6az servicebus namespace create --name FilterTest2 --resource-group FilterTest2 --location westus27# Add topic8az servicebus topic create --resource-group FilterTest2 --namespace-name FilterTest2 --9name FilterTest210# Add subscription 111az servicebus topic subscription create --resource-group FilterTest2 --namespace-name F12ilterTest2 --topic-name FilterTest2 --name S113# Add subscription 214az servicebus topic subscription create --resource-group FilterTest2 --namespace-name F15ilterTest2 --topic-name FilterTest2 --name S216# Add subscription 317az servicebus topic subscription create --resource-group FilterTest2 --namespace-name F18ilterTest2 --topic-name FilterTest2 --name S319# Add filter 120az servicebus topic subscription rule create --resource-group FilterTest2 --namespace-name FilterTest2 --topic-name FilterTest2 --subscription-name --name MyFilter --filter-sql-expression "StoreId = 'Store1'"21az servicebus topic subscription rule create --resource-group FilterTest2 --namespace-name FilterTest2 --topic-name FilterTest2 --subscription-name S1 --name MyFilter --filter-sql-expression "StoreId = 'Store1'"22# Add filter 223az servicebus topic subscription rule create --resource-group FilterTest2 --namespace-name FilterTest2 --topic-name FilterTest2 --subscription-name S2 --name MyFilter --filter-sql-expression "StoreId = 'Store2'"24# Add filter 325az servicebus topic subscription rule create --resource-group FilterTest2 --namespace-name FilterTest2 --topic-name FilterTest2 --subscription-name S3 --name MyFilter --filter-sql-expression "StoreId = 'Store3'"26# Get your access key for later...
Using AI Code Generation
1import { MockBuilder, MockRender } from 'ng-mocks';2import { AppModule } from './app.module';3beforeEach(() => MockBuilder(AppModule));4describe('AppComponent', () => {5 it('should create the app', () => {6 const fixture = MockRender(AppComponent);7 const app = fixture.debugElement.componentInstance;8 expect(app).toBeTruthy();9 });10});11import { MockBuilder, MockRender } from 'ng-mocks';12import { AppComponent } from './app.component';13import { AppModule } from './app.module';14beforeEach(() => MockBuilder(AppComponent, AppModule));15describe('AppComponent', () => {16 it('should create the app', () => {17 const fixture = MockRender(AppComponent);18 const app = fixture.debugElement.componentInstance;19 expect(app).toBeTruthy();20 });21});22import { MockBuilder, MockRender } from 'ng-mocks';23import { AppModule } from './app.module';24beforeEach(() => MockBuilder(AppModule));25describe('AppComponent', () => {26 it('should create the app', () => {27 const fixture = MockRender(AppComponent);28 const app = fixture.debugElement.componentInstance;29 expect(app).toBeTruthy();30 });31});32import { MockBuilder, MockRender } from 'ng-mocks';33import { AppComponent } from './app.component';34import { AppModule } from './app.module';35beforeEach(() => MockBuilder(AppComponent, AppModule));36describe('AppComponent', () => {37 it('should create the app', () => {38 const fixture = MockRender(AppComponent);39 const app = fixture.debugElement.componentInstance;40 expect(app).toBeTruthy();41 });42});43import { MockBuilder, MockRender } from 'ng-mocks';44import { AppModule } from './app.module';45beforeEach(() => MockBuilder(AppModule));46describe('AppComponent', () => {47 it('should create the app', () => {48 const fixture = MockRender(AppComponent);49 const app = fixture.debugElement.componentInstance;50 expect(app
Using AI Code Generation
1import { test2 } from 'ng-mocks';2import { test2 } from 'ng-mocks';3import { test2 } from 'ng-mocks';4import { test2 } from 'ng-mocks';5import { test2 } from 'ng-mocks';6import { test2 } from 'ng-mocks';7import { test2 } from 'ng-mocks';8import { test2 } from 'ng-mocks';9import { test2 } from 'ng-mocks';10import { test2 } from 'ng-mocks';11import { test2 } from 'ng-mocks';12import { test2 } from 'ng-mocks';13import { test2 } from 'ng-mocks';14import { test2 } from 'ng-mocks';15import { test2 } from 'ng-mocks';16import { test2 } from 'ng-mocks';17import { test2 } from 'ng-mocks';18import { test2 } from 'ng-mocks';19import { test2 } from 'ng-mocks';
Using AI Code Generation
1import { test2 } from 'ng-mocks';2import { test2 } from 'ng-mocks/dist/lib/mock-helper';3import { test2 } from 'ng-mocks';4import { test2 } from 'ng-mocks/dist/lib/mock-helper';5expect(spy).toHaveBeenCalledTimes(1);6expect(spy).toHaveBeenCalledWith(arg1, arg2);7expect(spy).toHaveBeenCalledWithOnce(arg1, arg2);8expect(spy).toHaveBeenCalledTimes(1);9expect(spy).toHaveBeenCalledWith(arg1, arg2);10expect(spy).toHaveBeenCalledWithOnceExactly(arg1, arg2);11expect(spy).toHaveBeenCalledTimes(1);12expect(spy).toHaveBeenCalledWith(arg1, arg2);13expect(spy).toHaveBeenCalledWithOnceLike(arg1, arg2);14expect(spy).toHaveBeenCalledTimes(1);15expect(spy).toHaveBeenCalledWith(arg1, arg2);16expect(spy).toHaveBeenCalledWithOnceLike(arg1, arg2);17expect(spy).toHaveBeenCalledTimes(1);18expect(spy).toHaveBeenCalledWith(arg1, arg2);19expect(spy).toHaveBeenCalledWithOnceAny(arg1, arg2);20expect(spy).toHaveBeenCalledTimes(1);21expect(spy).toHaveBeenCalledWith(arg1, arg2);22expect(spy).toHaveBeenCalledWithOnceAny(arg1, arg2);23expect(spy).toHaveBeenCalledTimes(1);24expect(spy).toHaveBeenCalledWith(arg1, arg2);25expect(spy).toHaveBeenCalledWithOnceAny(arg1, arg2);26expect(spy).toHaveBeenCalledTimes(1);27expect(spy).toHaveBeenCalledWith(arg1, arg2);28expect(spy).toHaveBeenCalledWithOnceAny(arg1, arg2);
Using AI Code Generation
1import { test2 } from 'ng-mocks';2import { MyComponent } from './my.component';3describe('MyComponent', () => {4 it('should render', () => {5 const fixture = test2(MyComponent);6 expect(fixture.nativeElement).toMatchSnapshot();7 });8});
Using AI Code Generation
1import { test2 } from 'ng-mocks';2import { MyComponentMock } from './my-component.mock';3import { MyComponent } from './my-component';4describe('test2', () => {5 it('should work', () => {6 const fixture = test2(MyComponentMock, { some: 'data' });7 const fixture = test2(MyComponent, { some: 'data' });8 });9});10import { testDirective } from 'ng-mocks';11import { MyDirectiveMock } from './my-directive.mock';12import { MyDirective } from './my-directive';13describe('testDirective', () => {14 it('should work', () => {15 const fixture = testDirective(MyDirectiveMock, { some: 'data' });16 const fixture = testDirective(MyDirective, { some: 'data' });17 });18});19import { testPipe } from 'ng-mocks';20import { MyPipeMock } from './my-pipe.mock';21import { MyPipe } from './my-pipe';22describe('testPipe', () => {23 it('should work', () => {24 const fixture = testPipe(MyPipeMock, { some: 'data' });25 const fixture = testPipe(MyPipe, { some: 'data' });26 });27});
Using AI Code Generation
1import { test2 } from 'ng-mocks';2test2('component', MyComponent, { /* inputs */ }, { /* outputs */ });3import { test2 } from 'ng-mocks';4test2('module', MyModule, { /* imports */ }, { /* declarations */ }, { /* providers */ }, { /* schemas */ });5import { test2 } from 'ng-mocks';6test2('service', MyService, { /* imports */ }, { /* providers */ });7import { test2 } from 'ng-mocks';8test2('pipe', MyPipe, { /* imports */ }, { /* declarations */ }, { /* providers */ });9import { test2 } from 'ng-mocks';10test2('directive', MyDirective, { /* imports */ }, { /* declarations */ }, { /* providers */ });11import { test2 } from 'ng-mocks';12test2('component', MyComponent, { /* inputs */ }, { /* outputs */ }, { /* template */ });13import { test2 } from 'ng-mocks';14test2('module', MyModule, { /* imports */ }, { /* declarations */ }, { /* providers */ }, { /* schemas */ }, { /* template */ });15import { test2 } from 'ng-mocks';16test2('service', MyService, { /* imports */ }, { /* providers */ }, { /* template */ });
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!!