{"id":395045,"date":"2024-06-29T11:59:08","date_gmt":"2024-06-29T11:59:08","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=395045"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=395045","title":{"rendered":"<span>Swift Power Assert<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/fbe\/f95\/070\/fbef95070ef38a8edee62ae47b192ce5.png\" width=\"1100\" height=\"550\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/fbe\/f95\/070\/fbef95070ef38a8edee62ae47b192ce5.png\"\/><\/figure>\n<p>Power asserts (\u0442\u0430\u043a\u0436\u0435 \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u044b\u0435 \u043a\u0430\u043a \u0434\u0438\u0430\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0443\u0442\u0432\u0435\u0440\u0436\u0434\u0435\u043d\u0438\u044f) \u0434\u043e\u043f\u043e\u043b\u043d\u044f\u044e\u0442 \u0432\u0430\u0448\u0438 \u043e\u0448\u0438\u0431\u043a\u0438 \u0443\u0442\u0432\u0435\u0440\u0436\u0434\u0435\u043d\u0438\u0439 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0435\u0439 \u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u0445, \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0445 \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u043e\u0446\u0435\u043d\u043a\u0438 \u0443\u0441\u043b\u043e\u0432\u0438\u044f, \u0438 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0442 \u0435\u0435 \u0432 \u043b\u0435\u0433\u043a\u043e \u0443\u0441\u0432\u0430\u0438\u0432\u0430\u0435\u043c\u043e\u0439 \u0444\u043e\u0440\u043c\u0435. Power asserts \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0435\u0439\u00a0<a href=\"https:\/\/github.com\/spockframework\/spock\" rel=\"noopener noreferrer nofollow\">Spock<\/a>\u00a0(\u0430 \u043f\u043e\u0437\u0436\u0435 \u0438 \u0432\u0441\u0435\u0433\u043e \u044f\u0437\u044b\u043a\u0430\u00a0<a href=\"https:\/\/github.com\/apache\/groovy\" rel=\"noopener noreferrer nofollow\">Groovy<\/a>\u00a0\u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e \u043e\u0442 Spock),\u00a0<a href=\"http:\/\/www.scalatest.org\/\" rel=\"noopener noreferrer nofollow\">ScalaTest<\/a>\u00a0\u0438\u00a0<a href=\"https:\/\/github.com\/pniederw\/expecty\" rel=\"noopener noreferrer nofollow\">Expecty<\/a>.<\/p>\n<p>Power asserts \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0442 \u043e\u043f\u0438\u0441\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u043e\u0431 \u0443\u0442\u0432\u0435\u0440\u0436\u0434\u0435\u043d\u0438\u044f\u0445 \u0434\u043b\u044f \u0432\u0430\u0448\u0438\u0445 \u0442\u0435\u0441\u0442\u043e\u0432, \u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0435 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0430\u043c:<\/p>\n<pre><code class=\"swift\">#expect(max(a, b) == c)         |   |  |  |  |         7   4  7  |  12                   false  #expect(xs.contains(4))         |  |        |         |  false    4         [1, 2, 3]  #expect(\"hello\".hasPrefix(\"h\") &amp;&amp; \"goodbye\".hasSuffix(\"y\"))         |       |         |    |  |         |         |         \"hello\" true      \"h\"  |  \"goodbye\" false     \"y\"                               false<\/code><\/pre>\n<h3>\u041f\u043e\u0447\u0435\u043c\u0443 Power Assert?<\/h3>\n<p>\u041f\u0440\u0438 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u0438 \u0442\u0435\u0441\u0442\u043e\u0432 \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0443\u0442\u0432\u0435\u0440\u0436\u0434\u0435\u043d\u0438\u0439. \u0421 \u043f\u043e\u043c\u043e\u0449\u044c\u044e Power Assert \u0432\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u044e\u00a0<a href=\"https:\/\/vc.ru\/tag\/expect\" rel=\"noopener noreferrer nofollow\"><strong>#expect<\/strong><\/a><strong>()<\/strong>. \u041d\u0435\u0442 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u0437\u0430\u043f\u043e\u043c\u0438\u043d\u0430\u0442\u044c \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e Assertion API. \u041f\u0440\u043e\u0441\u0442\u043e \u0441\u043e\u0437\u0434\u0430\u0439\u0442\u0435 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0431\u0443\u043b\u0435\u0432\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435, \u0438 Power Assert \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043e\u0442\u043e\u0431\u0440\u0430\u0437\u0438\u0442 \u0438\u0441\u0447\u0435\u0440\u043f\u044b\u0432\u0430\u044e\u0449\u0443\u044e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e\u0431 \u043e\u0448\u0438\u0431\u043a\u0435.<\/p>\n<h3>\u041d\u0430\u0447\u0430\u043b\u043e \u0440\u0430\u0431\u043e\u0442\u044b<\/h3>\n<p>Swift Power Assert \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e\u00a0<a href=\"https:\/\/github.com\/apple\/swift-evolution\/blob\/main\/proposals\/0382-expression-macros.md\" rel=\"noopener noreferrer nofollow\">\u043c\u0430\u043a\u0440\u043e\u0441\u043e\u0432<\/a>, \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u0430\u043b\u044c\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 Swift. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u0435\u0434\u0432\u0430\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u0443\u044e \u0432\u0435\u0440\u0441\u0438\u044e \u043d\u0430\u0431\u043e\u0440\u0430 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432 Swift, \u0447\u0442\u043e\u0431\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u044d\u0442\u0443 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443.<\/p>\n<ol>\n<li>\n<p>\u0421\u043a\u0430\u0447\u0430\u0439\u0442\u0435 \u0438 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0435 \u043d\u0430\u0431\u043e\u0440 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u0438\u0437\u00a0<a href=\"https:\/\/www.swift.org\/download\/\" rel=\"noopener noreferrer nofollow\">\u0441\u043d\u0430\u043f\u0448\u043e\u0442\u0430 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043d\u0430 swift.org<\/a>\u00a0\u043f\u043e\u0441\u043b\u0435 6 \u0430\u043f\u0440\u0435\u043b\u044f 2023 \u0433\u043e\u0434\u0430.<\/p>\n<\/li>\n<li>\n<p>\u0423\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0435 \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440 \u043d\u0430\u0431\u043e\u0440\u0430 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u0432 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u044f\u00a0<strong>TOOLCHAINS<\/strong>, \u0447\u0442\u043e\u0431\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u043f\u0440\u0435\u0434\u0432\u0430\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u0443\u044e \u0432\u0435\u0440\u0441\u0438\u044e. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<\/li>\n<\/ol>\n<pre><code class=\"swift\">export TOOLCHAINS=org.swift.59202303301a<\/code><\/pre>\n<p>\u041f\u0440\u0438\u043c\u0435\u0447\u0430\u043d\u0438\u0435: \u0427\u0442\u043e\u0431\u044b \u0443\u0437\u043d\u0430\u0442\u044c \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440 \u043d\u0430\u0431\u043e\u0440\u0430 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432, \u043f\u0440\u043e\u0432\u0435\u0440\u044c\u0442\u0435 \u0444\u0430\u0439\u043b Info.plist \u0432 \u043d\u0430\u0431\u043e\u0440\u0435 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432. \u041d\u0430\u0431\u043e\u0440\u044b \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u043e\u0431\u044b\u0447\u043d\u043e \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u044e\u0442\u0441\u044f \u0432 `\/Library\/Developer\/Toolchains\/&#8217;. \u0429\u0435\u043b\u043a\u043d\u0438\u0442\u0435 \u043f\u0440\u0430\u0432\u043e\u0439 \u043a\u043d\u043e\u043f\u043a\u043e\u0439 \u043c\u044b\u0448\u0438 \u043d\u0430 \u0437\u043d\u0430\u0447\u043a\u0435 \u043d\u0430\u0431\u043e\u0440\u0430 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u0438 \u0432\u044b\u0431\u0435\u0440\u0438\u0442\u0435 &#171;\u041f\u043e\u043a\u0430\u0437\u0430\u0442\u044c \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 \u043f\u0430\u043a\u0435\u0442\u0430&#187;, \u0447\u0442\u043e\u0431\u044b \u043d\u0430\u0439\u0442\u0438 \u0444\u0430\u0439\u043b Info.plist. \u0417\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043a\u043b\u044e\u0447\u0430 Bundle Identifier \u0432 \u0444\u0430\u0439\u043b\u0435 Info.plist \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440\u043e\u043c \u043d\u0430\u0431\u043e\u0440\u0430 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432. \u0414\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u0443\u044e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u0432 \u043e\u0442\u043b\u0438\u0447\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u0421\u0430\u0440\u0443\u043d\u0430:\u00a0<a href=\"https:\/\/sarunw.com\/posts\/how-to-use-pre-release-swift-version-with-command-line-tools\/\" rel=\"noopener noreferrer nofollow\">https:\/\/sarunw.com\/posts\/how-to-use-pre-release-swift-version-with-command-line-tools\/<\/a><\/p>\n<h3>\u041f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u0440\u0430\u0431\u043e\u0442\u044b<\/h3>\n<p>\u0427\u0442\u043e\u0431\u044b \u0443\u0432\u0438\u0434\u0435\u0442\u044c PowerAssert \u0432 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0438, \u043f\u0435\u0440\u0435\u0439\u0434\u0438\u0442\u0435 \u0432 \u043a\u0430\u0442\u0430\u043b\u043e\u0433 Examples \u0438 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u0435\u00a0<strong>swift test<\/strong>.<\/p>\n<pre><code class=\"swift\">$ cd Example $ swift test<\/code><\/pre>\n<p>\u0412\u0438\u0434\u0438\u0442\u0435 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b?  <\/p>\n<pre><code class=\"swift\">... Test Suite 'All tests' started at 2023-04-05 07:17:58.800 Test Suite 'swift-power-assert-examplePackageTests.xctest' started at 2023-04-05 07:17:58.801 Test Suite 'PowerAssertTests' started at 2023-04-05 07:17:58.801 Test Case '-[ExampleTests.PowerAssertTests testExample]' started. \/swift-power-assert\/Example\/\"ExampleTests\/ExampleTests.swift\":8: error: -[ExampleTests.PowerAssertTests testExample] : failed - #expect(a * b == 91)         |   | |  |         10  9 |  91               false \/swift-power-assert\/Example\/\"ExampleTests\/ExampleTests.swift\":11: error: -[ExampleTests.PowerAssertTests testExample] : failed - #expect(xs.contains(4))         |  |        |         |  false    4         [1, 2, 3] \u2026<\/code><\/pre>\n<p>\u041c\u0435\u043d\u044f\u0439\u0442\u0435 \u043a\u043e\u0434 \u0432\u00a0<strong>Example\/Tests\/ExampleTests.swift<\/strong>, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u0442\u044c \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u0430\u043c \u043d\u0440\u0430\u0432\u044f\u0442\u0441\u044f.<\/p>\n<h3>\u041f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u0435<\/h3>\n<p>\u0427\u0442\u043e\u0431\u044b \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u0442\u044c Swift Power Assert \u0432 \u0432\u0430\u0448\u0435\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0435 \u0438\u043b\u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438, \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0434\u043e\u0431\u0430\u0432\u044c\u0442\u0435 SwiftPowerAssert \u0432 \u043c\u0435\u043d\u0435\u0434\u0436\u0435\u0440 \u043f\u0430\u043a\u0435\u0442\u043e\u0432 Swift.<\/p>\n<pre><code class=\"swift\">\/\/ swift-tools-version:5.8 import PackageDescription  let package = Package(   name: \"MyLibrary\",   dependencies: [     ...,     .package(         url: \"https:\/\/github.com\/kishikawakatsumi\/swift-power-assert.git\",         branch: \"main\"     ),   ],   targets: [     ...,     .testTarget(       name: \"MyLibraryTests\",       dependencies: [         ...,         .product(name: \"PowerAssert\", package: \"swift-power-assert\"),       ]     ),   ] )<\/code><\/pre>\n<p>\u0414\u0430\u043b\u0435\u0435 \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c Power Assert \u0432 \u0432\u0430\u0448\u0438\u0445 \u0442\u0435\u0441\u0442\u0430\u0445 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043c\u0430\u043a\u0440\u043e\u0441\u0430\u00a0<a href=\"https:\/\/vc.ru\/tag\/expect\" rel=\"noopener noreferrer nofollow\"><strong>#expect<\/strong><\/a><strong>()<\/strong>.  <\/p>\n<pre><code class=\"swift\">\/\/ MyLibraryTests.swift import XCTest import PowerAssert @testable import MyLibrary  final class MyLibraryTests: XCTestCase {   func testExample() {     let a = 7     let b = 4     let c = 12      #expect(max(a, b) == c)   } }<\/code><\/pre>\n<h3>\u0417\u0430\u043f\u0440\u043e\u0441 \u043e \u043f\u043e\u043c\u043e\u0449\u0438 \u0432 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0438<\/h3>\n<p>Swift Power Assert \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u043d\u0430 \u0440\u0430\u043d\u043d\u0438\u0445 \u0441\u0442\u0430\u0434\u0438\u044f\u0445 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438. \u0415\u0441\u043b\u0438 \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u043e\u043c\u043e\u0447\u044c \u043d\u0430\u043c \u0441 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435\u043c, \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u043e\u0447\u0435\u043d\u044c \u043f\u0440\u0438\u0437\u043d\u0430\u0442\u0435\u043b\u044c\u043d\u044b! \u041f\u043e\u0436\u0430\u043b\u0443\u0439\u0441\u0442\u0430, \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0439\u0442\u0435 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u044b \u043a\u043e\u0434\u0430 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u044d\u0442\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u0438 \u043f\u0438\u0448\u0438\u0442\u0435 \u043e \u043b\u044e\u0431\u044b\u0445 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430\u0445, \u0441 \u043a\u043e\u0442\u043e\u0440\u044b\u043c\u0438 \u0432\u044b \u0441\u0442\u043e\u043b\u043a\u043d\u0443\u043b\u0438\u0441\u044c. \u041c\u044b \u043f\u0440\u0438\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u043c \u0432\u0430\u0448\u0438 \u043e\u0442\u0437\u044b\u0432\u044b \u0438 \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043f\u043e \u0443\u043b\u0443\u0447\u0448\u0435\u043d\u0438\u044e. \u0411\u043e\u043b\u044c\u0448\u043e\u0435 \u0441\u043f\u0430\u0441\u0438\u0431\u043e!<\/p>\n<h3>\u0427\u0430\u0441\u0442\u043e \u0437\u0430\u0434\u0430\u0432\u0430\u0435\u043c\u044b\u0435 \u0432\u043e\u043f\u0440\u043e\u0441\u044b<\/h3>\n<p><strong>\u0412: \u042f \u0445\u043e\u0447\u0443 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0442\u044c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0434\u0430\u0436\u0435 \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u0443\u0441\u043f\u0435\u0448\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u044f \u0442\u0435\u0441\u0442\u0430 (\u0442.\u0435. \u0435\u0441\u043b\u0438 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u0438\u00a0<\/strong><a href=\"https:\/\/vc.ru\/tag\/expect\" rel=\"noopener noreferrer nofollow\"><strong>#expect<\/strong><\/a><strong>() \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0435\u0442\u0441\u044f \u0432 true).<\/strong><\/p>\n<p>\u041e: \u041f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044f\u00a0<a href=\"https:\/\/vc.ru\/tag\/expect\" rel=\"noopener noreferrer nofollow\"><strong>#expect<\/strong><\/a><strong>()<\/strong>\u00a0\u043d\u0435 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0435\u0442 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442, \u0435\u0441\u043b\u0438 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0435\u0442\u0441\u044f \u0432\u00a0<strong>true<\/strong>, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0442\u0435\u0441\u0442 \u0431\u044b\u043b \u0443\u0441\u043f\u0435\u0448\u043d\u044b\u043c. \u0427\u0442\u043e\u0431\u044b \u0432\u0441\u0435\u0433\u0434\u0430 \u0432\u044b\u0432\u043e\u0434\u0438\u0442\u044c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442, \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0435 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u00a0<strong>verbose\u00a0<\/strong>\u0432 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u00a0<strong>true<\/strong>.<\/p>\n<p>\u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<pre><code class=\"swift\">#expect(x == y, verbose: true)<\/code><\/pre>\n<p><strong>\u0412: \u042f \u0445\u043e\u0447\u0443 \u0437\u043d\u0430\u0442\u044c, \u043a\u0430\u043a \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 \u043d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 \u0440\u0430\u0441\u043a\u0440\u044b\u043b \u043c\u0430\u043a\u0440\u043e\u0441.<\/strong><\/p>\n<p>\u041e: \u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043e\u043f\u0446\u0438\u044e -dump-macro-expansions \u0434\u043b\u044f \u0432\u044b\u0432\u043e\u0434\u0430 \u0440\u0430\u0441\u043a\u0440\u044b\u0442\u0438\u044f \u043c\u0430\u043a\u0440\u043e\u0441\u0430.<\/p>\n<p>\u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<pre><code class=\"swift\">$ cd Example  $ swift test -Xswiftc -Xfrontend -Xswiftc -dump-macro-expansions<\/code><\/pre>\n<p>\u0415\u0441\u043b\u0438 \u0432\u044b \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u0435 \u0432\u044b\u0448\u0435\u0443\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u0435 \u0441 \u043e\u043f\u0446\u0438\u0435\u0439\u00a0<strong>-dump-macro-expansions<\/strong>, \u0432\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0435 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0432\u044b\u0432\u043e\u0434.  <\/p>\n<pre><code class=\"swift\">... @__swiftmacro_12ExampleTests011PowerAssertB0C04testA0yyF6expectfMf_.swift as () ------------------------------          PowerAssert.Assertion(\"#expect(a * b == 91)\", message: \"\", file: #\"\"ExampleTests\/ExampleTests.swift\"\"#, line: 8, verbose: false) {   $0.capture($0.capture($0.capture(a .self, column: 8) * $0.capture(b .self, column: 12), column: 10) == $0.capture(91, column: 17), column: 14) } .render() ------------------------------ ...<\/code><\/pre>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/730788\/\"> https:\/\/habr.com\/ru\/articles\/730788\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<figure class=\"full-width\"><\/figure>\n<p>Power asserts (\u0442\u0430\u043a\u0436\u0435 \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u044b\u0435 \u043a\u0430\u043a \u0434\u0438\u0430\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0443\u0442\u0432\u0435\u0440\u0436\u0434\u0435\u043d\u0438\u044f) \u0434\u043e\u043f\u043e\u043b\u043d\u044f\u044e\u0442 \u0432\u0430\u0448\u0438 \u043e\u0448\u0438\u0431\u043a\u0438 \u0443\u0442\u0432\u0435\u0440\u0436\u0434\u0435\u043d\u0438\u0439 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0435\u0439 \u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u0445, \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0445 \u0432\u043e \u0432\u0440\u0435\u043c\u044f \u043e\u0446\u0435\u043d\u043a\u0438 \u0443\u0441\u043b\u043e\u0432\u0438\u044f, \u0438 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0442 \u0435\u0435 \u0432 \u043b\u0435\u0433\u043a\u043e \u0443\u0441\u0432\u0430\u0438\u0432\u0430\u0435\u043c\u043e\u0439 \u0444\u043e\u0440\u043c\u0435. Power asserts \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u043f\u043e\u043f\u0443\u043b\u044f\u0440\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0435\u0439\u00a0<a href=\"https:\/\/github.com\/spockframework\/spock\" rel=\"noopener noreferrer nofollow\">Spock<\/a>\u00a0(\u0430 \u043f\u043e\u0437\u0436\u0435 \u0438 \u0432\u0441\u0435\u0433\u043e \u044f\u0437\u044b\u043a\u0430\u00a0<a href=\"https:\/\/github.com\/apache\/groovy\" rel=\"noopener noreferrer nofollow\">Groovy<\/a>\u00a0\u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e \u043e\u0442 Spock),\u00a0<a href=\"http:\/\/www.scalatest.org\/\" rel=\"noopener noreferrer nofollow\">ScalaTest<\/a>\u00a0\u0438\u00a0<a href=\"https:\/\/github.com\/pniederw\/expecty\" rel=\"noopener noreferrer nofollow\">Expecty<\/a>.<\/p>\n<p>Power asserts \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0442 \u043e\u043f\u0438\u0441\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u043e\u0431 \u0443\u0442\u0432\u0435\u0440\u0436\u0434\u0435\u043d\u0438\u044f\u0445 \u0434\u043b\u044f \u0432\u0430\u0448\u0438\u0445 \u0442\u0435\u0441\u0442\u043e\u0432, \u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0435 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0430\u043c:<\/p>\n<pre><code class=\"swift\">#expect(max(a, b) == c)         |   |  |  |  |         7   4  7  |  12                   false  #expect(xs.contains(4))         |  |        |         |  false    4         [1, 2, 3]  #expect(\"hello\".hasPrefix(\"h\") &amp;&amp; \"goodbye\".hasSuffix(\"y\"))         |       |         |    |  |         |         |         \"hello\" true      \"h\"  |  \"goodbye\" false     \"y\"                               false<\/code><\/pre>\n<h3>\u041f\u043e\u0447\u0435\u043c\u0443 Power Assert?<\/h3>\n<p>\u041f\u0440\u0438 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u0438 \u0442\u0435\u0441\u0442\u043e\u0432 \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0443\u0442\u0432\u0435\u0440\u0436\u0434\u0435\u043d\u0438\u0439. \u0421 \u043f\u043e\u043c\u043e\u0449\u044c\u044e Power Assert \u0432\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u044e\u00a0<a href=\"https:\/\/vc.ru\/tag\/expect\" rel=\"noopener noreferrer nofollow\"><strong>#expect<\/strong><\/a><strong>()<\/strong>. \u041d\u0435\u0442 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u0437\u0430\u043f\u043e\u043c\u0438\u043d\u0430\u0442\u044c \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e Assertion API. \u041f\u0440\u043e\u0441\u0442\u043e \u0441\u043e\u0437\u0434\u0430\u0439\u0442\u0435 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0431\u0443\u043b\u0435\u0432\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435, \u0438 Power Assert \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043e\u0442\u043e\u0431\u0440\u0430\u0437\u0438\u0442 \u0438\u0441\u0447\u0435\u0440\u043f\u044b\u0432\u0430\u044e\u0449\u0443\u044e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e\u0431 \u043e\u0448\u0438\u0431\u043a\u0435.<\/p>\n<h3>\u041d\u0430\u0447\u0430\u043b\u043e \u0440\u0430\u0431\u043e\u0442\u044b<\/h3>\n<p>Swift Power Assert \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e\u00a0<a href=\"https:\/\/github.com\/apple\/swift-evolution\/blob\/main\/proposals\/0382-expression-macros.md\" rel=\"noopener noreferrer nofollow\">\u043c\u0430\u043a\u0440\u043e\u0441\u043e\u0432<\/a>, \u044d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u0430\u043b\u044c\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 Swift. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u0435\u0434\u0432\u0430\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u0443\u044e \u0432\u0435\u0440\u0441\u0438\u044e \u043d\u0430\u0431\u043e\u0440\u0430 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432 Swift, \u0447\u0442\u043e\u0431\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u044d\u0442\u0443 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443.<\/p>\n<ol>\n<li>\n<p>\u0421\u043a\u0430\u0447\u0430\u0439\u0442\u0435 \u0438 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0435 \u043d\u0430\u0431\u043e\u0440 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u0438\u0437\u00a0<a href=\"https:\/\/www.swift.org\/download\/\" rel=\"noopener noreferrer nofollow\">\u0441\u043d\u0430\u043f\u0448\u043e\u0442\u0430 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u043d\u0430 swift.org<\/a>\u00a0\u043f\u043e\u0441\u043b\u0435 6 \u0430\u043f\u0440\u0435\u043b\u044f 2023 \u0433\u043e\u0434\u0430.<\/p>\n<\/li>\n<li>\n<p>\u0423\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0435 \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440 \u043d\u0430\u0431\u043e\u0440\u0430 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u0432 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u044f\u00a0<strong>TOOLCHAINS<\/strong>, \u0447\u0442\u043e\u0431\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u043f\u0440\u0435\u0434\u0432\u0430\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u0443\u044e \u0432\u0435\u0440\u0441\u0438\u044e. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<\/li>\n<\/ol>\n<pre><code class=\"swift\">export TOOLCHAINS=org.swift.59202303301a<\/code><\/pre>\n<p>\u041f\u0440\u0438\u043c\u0435\u0447\u0430\u043d\u0438\u0435: \u0427\u0442\u043e\u0431\u044b \u0443\u0437\u043d\u0430\u0442\u044c \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440 \u043d\u0430\u0431\u043e\u0440\u0430 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432, \u043f\u0440\u043e\u0432\u0435\u0440\u044c\u0442\u0435 \u0444\u0430\u0439\u043b Info.plist \u0432 \u043d\u0430\u0431\u043e\u0440\u0435 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432. \u041d\u0430\u0431\u043e\u0440\u044b \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u043e\u0431\u044b\u0447\u043d\u043e \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u044e\u0442\u0441\u044f \u0432 `\/Library\/Developer\/Toolchains\/&#8217;. \u0429\u0435\u043b\u043a\u043d\u0438\u0442\u0435 \u043f\u0440\u0430\u0432\u043e\u0439 \u043a\u043d\u043e\u043f\u043a\u043e\u0439 \u043c\u044b\u0448\u0438 \u043d\u0430 \u0437\u043d\u0430\u0447\u043a\u0435 \u043d\u0430\u0431\u043e\u0440\u0430 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u0438 \u0432\u044b\u0431\u0435\u0440\u0438\u0442\u0435 &#171;\u041f\u043e\u043a\u0430\u0437\u0430\u0442\u044c \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 \u043f\u0430\u043a\u0435\u0442\u0430&#187;, \u0447\u0442\u043e\u0431\u044b \u043d\u0430\u0439\u0442\u0438 \u0444\u0430\u0439\u043b Info.plist. \u0417\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043a\u043b\u044e\u0447\u0430 Bundle Identifier \u0432 \u0444\u0430\u0439\u043b\u0435 Info.plist \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440\u043e\u043c \u043d\u0430\u0431\u043e\u0440\u0430 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u0432. \u0414\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u0443\u044e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u0432 \u043e\u0442\u043b\u0438\u0447\u043d\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u0421\u0430\u0440\u0443\u043d\u0430:\u00a0<a href=\"https:\/\/sarunw.com\/posts\/how-to-use-pre-release-swift-version-with-command-line-tools\/\" rel=\"noopener noreferrer nofollow\">https:\/\/sarunw.com\/posts\/how-to-use-pre-release-swift-version-with-command-line-tools\/<\/a><\/p>\n<h3>\u041f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u0440\u0430\u0431\u043e\u0442\u044b<\/h3>\n<p>\u0427\u0442\u043e\u0431\u044b \u0443\u0432\u0438\u0434\u0435\u0442\u044c PowerAssert \u0432 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0438, \u043f\u0435\u0440\u0435\u0439\u0434\u0438\u0442\u0435 \u0432 \u043a\u0430\u0442\u0430\u043b\u043e\u0433 Examples \u0438 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u0435\u00a0<strong>swift test<\/strong>.<\/p>\n<pre><code class=\"swift\">$ cd Example $ swift test<\/code><\/pre>\n<p>\u0412\u0438\u0434\u0438\u0442\u0435 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b?  <\/p>\n<pre><code class=\"swift\">... Test Suite 'All tests' started at 2023-04-05 07:17:58.800 Test Suite 'swift-power-assert-examplePackageTests.xctest' started at 2023-04-05 07:17:58.801 Test Suite 'PowerAssertTests' started at 2023-04-05 07:17:58.801 Test Case '-[ExampleTests.PowerAssertTests testExample]' started. \/swift-power-assert\/Example\/\"ExampleTests\/ExampleTests.swift\":8: error: -[ExampleTests.PowerAssertTests testExample] : failed - #expect(a * b == 91)         |   | |  |         10  9 |  91               false \/swift-power-assert\/Example\/\"ExampleTests\/ExampleTests.swift\":11: error: -[ExampleTests.PowerAssertTests testExample] : failed - #expect(xs.contains(4))         |  |        |         |  false    4         [1, 2, 3] \u2026<\/code><\/pre>\n<p>\u041c\u0435\u043d\u044f\u0439\u0442\u0435 \u043a\u043e\u0434 \u0432\u00a0<strong>Example\/Tests\/ExampleTests.swift<\/strong>, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043f\u0440\u043e\u0431\u043e\u0432\u0430\u0442\u044c \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u0430\u043c \u043d\u0440\u0430\u0432\u044f\u0442\u0441\u044f.<\/p>\n<h3>\u041f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u0435<\/h3>\n<p>\u0427\u0442\u043e\u0431\u044b \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u0442\u044c Swift Power Assert \u0432 \u0432\u0430\u0448\u0435\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0435 \u0438\u043b\u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438, \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0434\u043e\u0431\u0430\u0432\u044c\u0442\u0435 SwiftPowerAssert \u0432 \u043c\u0435\u043d\u0435\u0434\u0436\u0435\u0440 \u043f\u0430\u043a\u0435\u0442\u043e\u0432 Swift.<\/p>\n<pre><code class=\"swift\">\/\/ swift-tools-version:5.8 import PackageDescription  let package = Package(   name: \"MyLibrary\",   dependencies: [     ...,     .package(         url: \"https:\/\/github.com\/kishikawakatsumi\/swift-power-assert.git\",         branch: \"main\"     ),   ],   targets: [     ...,     .testTarget(       name: \"MyLibraryTests\",       dependencies: [         ...,         .product(name: \"PowerAssert\", package: \"swift-power-assert\"),       ]     ),   ] )<\/code><\/pre>\n<p>\u0414\u0430\u043b\u0435\u0435 \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c Power Assert \u0432 \u0432\u0430\u0448\u0438\u0445 \u0442\u0435\u0441\u0442\u0430\u0445 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043c\u0430\u043a\u0440\u043e\u0441\u0430\u00a0<a href=\"https:\/\/vc.ru\/tag\/expect\" rel=\"noopener noreferrer nofollow\"><strong>#expect<\/strong><\/a><strong>()<\/strong>.  <\/p>\n<pre><code class=\"swift\">\/\/ MyLibraryTests.swift import XCTest import PowerAssert @testable import MyLibrary  final class MyLibraryTests: XCTestCase {   func testExample() {     let a = 7     let b = 4     let c = 12      #expect(max(a, b) == c)   } }<\/code><\/pre>\n<h3>\u0417\u0430\u043f\u0440\u043e\u0441 \u043e \u043f\u043e\u043c\u043e\u0449\u0438 \u0432 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0438<\/h3>\n<p>Swift Power Assert \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u043d\u0430 \u0440\u0430\u043d\u043d\u0438\u0445 \u0441\u0442\u0430\u0434\u0438\u044f\u0445 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438. \u0415\u0441\u043b\u0438 \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u043e\u043c\u043e\u0447\u044c \u043d\u0430\u043c \u0441 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435\u043c, \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u043e\u0447\u0435\u043d\u044c \u043f\u0440\u0438\u0437\u043d\u0430\u0442\u0435\u043b\u044c\u043d\u044b! \u041f\u043e\u0436\u0430\u043b\u0443\u0439\u0441\u0442\u0430, \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0439\u0442\u0435 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u044b \u043a\u043e\u0434\u0430 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u044d\u0442\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u0438 \u043f\u0438\u0448\u0438\u0442\u0435 \u043e \u043b\u044e\u0431\u044b\u0445 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430\u0445, \u0441 \u043a\u043e\u0442\u043e\u0440\u044b\u043c\u0438 \u0432\u044b \u0441\u0442\u043e\u043b\u043a\u043d\u0443\u043b\u0438\u0441\u044c. \u041c\u044b \u043f\u0440\u0438\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u043c \u0432\u0430\u0448\u0438 \u043e\u0442\u0437\u044b\u0432\u044b \u0438 \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043f\u043e \u0443\u043b\u0443\u0447\u0448\u0435\u043d\u0438\u044e. \u0411\u043e\u043b\u044c\u0448\u043e\u0435 \u0441\u043f\u0430\u0441\u0438\u0431\u043e!<\/p>\n<h3>\u0427\u0430\u0441\u0442\u043e \u0437\u0430\u0434\u0430\u0432\u0430\u0435\u043c\u044b\u0435 \u0432\u043e\u043f\u0440\u043e\u0441\u044b<\/h3>\n<p><strong>\u0412: \u042f \u0445\u043e\u0447\u0443 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0442\u044c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0434\u0430\u0436\u0435 \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u0443\u0441\u043f\u0435\u0448\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u044f \u0442\u0435\u0441\u0442\u0430 (\u0442.\u0435. \u0435\u0441\u043b\u0438 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u0438\u00a0<\/strong><a href=\"https:\/\/vc.ru\/tag\/expect\" rel=\"noopener noreferrer nofollow\"><strong>#expect<\/strong><\/a><strong>() \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0435\u0442\u0441\u044f \u0432 true).<\/strong><\/p>\n<p>\u041e: \u041f\u043e \u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044f\u00a0<a href=\"https:\/\/vc.ru\/tag\/expect\" rel=\"noopener noreferrer nofollow\"><strong>#expect<\/strong><\/a><strong>()<\/strong>\u00a0\u043d\u0435 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0435\u0442 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442, \u0435\u0441\u043b\u0438 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0435\u0442\u0441\u044f \u0432\u00a0<strong>true<\/strong>, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0442\u0435\u0441\u0442 \u0431\u044b\u043b \u0443\u0441\u043f\u0435\u0448\u043d\u044b\u043c. \u0427\u0442\u043e\u0431\u044b \u0432\u0441\u0435\u0433\u0434\u0430 \u0432\u044b\u0432\u043e\u0434\u0438\u0442\u044c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442, \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0435 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u00a0<strong>verbose\u00a0<\/strong>\u0432 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u00a0<strong>true<\/strong>.<\/p>\n<p>\u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<pre><code class=\"swift\">#expect(x == y, verbose: true)<\/code><\/pre>\n<p><strong>\u0412: \u042f \u0445\u043e\u0447\u0443 \u0437\u043d\u0430\u0442\u044c, \u043a\u0430\u043a \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440 \u043d\u0430 \u0441\u0430\u043c\u043e\u043c \u0434\u0435\u043b\u0435 \u0440\u0430\u0441\u043a\u0440\u044b\u043b \u043c\u0430\u043a\u0440\u043e\u0441.<\/strong><\/p>\n<p>\u041e: \u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043e\u043f\u0446\u0438\u044e -dump-macro-expansions \u0434\u043b\u044f \u0432\u044b\u0432\u043e\u0434\u0430 \u0440\u0430\u0441\u043a\u0440\u044b\u0442\u0438\u044f \u043c\u0430\u043a\u0440\u043e\u0441\u0430.<\/p>\n<p>\u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<pre><code class=\"swift\">$ cd Example  $ swift test -Xswiftc -Xfrontend -Xswiftc -dump-macro-expansions<\/code><\/pre>\n<p>\u0415\u0441\u043b\u0438 \u0432\u044b \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u0435 \u0432\u044b\u0448\u0435\u0443\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u0435 \u0441 \u043e\u043f\u0446\u0438\u0435\u0439\u00a0<strong>-dump-macro-expansions<\/strong>, \u0432\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0435 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0432\u044b\u0432\u043e\u0434.  <\/p>\n<pre><code class=\"swift\">... @__swiftmacro_12ExampleTests011PowerAssertB0C04testA0yyF6expectfMf_.swift as () ------------------------------          PowerAssert.Assertion(\"#expect(a * b == 91)\", message: \"\", file: #\"\"ExampleTests\/ExampleTests.swift\"\"#, line: 8, verbose: false) {   $0.capture($0.capture($0.capture(a .self, column: 8) * $0.capture(b .self, column: 12), column: 10) == $0.capture(91, column: 17), column: 14) } .render() ------------------------------ ...<\/code><\/pre>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/730788\/\"> https:\/\/habr.com\/ru\/articles\/730788\/<\/a><br \/><\/br><\/br><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-395045","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/395045","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=395045"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/395045\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=395045"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=395045"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=395045"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}