@goast/kotlin 0.4.7-beta2 → 0.4.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (519) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +45 -45
  3. package/assets/client/okhttp3/ApiClient.kt +250 -250
  4. package/esm/_dnt.test_polyfills.d.ts +29 -0
  5. package/esm/_dnt.test_polyfills.d.ts.map +1 -0
  6. package/esm/_dnt.test_polyfills.js +31 -0
  7. package/esm/_dnt.test_shims.d.ts +6 -0
  8. package/esm/_dnt.test_shims.d.ts.map +1 -0
  9. package/esm/_dnt.test_shims.js +61 -0
  10. package/esm/deps/jsr.io/@std/assert/1.0.9/assertion_error.d.ts +26 -0
  11. package/esm/deps/jsr.io/@std/assert/1.0.9/assertion_error.d.ts.map +1 -0
  12. package/esm/deps/jsr.io/@std/assert/1.0.9/assertion_error.js +30 -0
  13. package/esm/deps/jsr.io/@std/assert/1.0.9/equal.d.ts +17 -0
  14. package/esm/deps/jsr.io/@std/assert/1.0.9/equal.d.ts.map +1 -0
  15. package/esm/deps/jsr.io/@std/assert/1.0.9/equal.js +183 -0
  16. package/esm/deps/jsr.io/@std/assert/1.0.9/equals.d.ts +35 -0
  17. package/esm/deps/jsr.io/@std/assert/1.0.9/equals.d.ts.map +1 -0
  18. package/esm/deps/jsr.io/@std/assert/1.0.9/equals.js +58 -0
  19. package/esm/deps/jsr.io/@std/assert/1.0.9/false.d.ts +18 -0
  20. package/esm/deps/jsr.io/@std/assert/1.0.9/false.d.ts.map +1 -0
  21. package/esm/deps/jsr.io/@std/assert/1.0.9/false.js +22 -0
  22. package/esm/deps/jsr.io/@std/assert/1.0.9/instance_of.d.ts +23 -0
  23. package/esm/deps/jsr.io/@std/assert/1.0.9/instance_of.d.ts.map +1 -0
  24. package/esm/deps/jsr.io/@std/assert/1.0.9/instance_of.js +53 -0
  25. package/esm/deps/jsr.io/@std/assert/1.0.9/is_error.d.ts +25 -0
  26. package/esm/deps/jsr.io/@std/assert/1.0.9/is_error.d.ts.map +1 -0
  27. package/esm/deps/jsr.io/@std/assert/1.0.9/is_error.js +54 -0
  28. package/esm/deps/jsr.io/@std/assert/1.0.9/match.d.ts +18 -0
  29. package/esm/deps/jsr.io/@std/assert/1.0.9/match.d.ts.map +1 -0
  30. package/esm/deps/jsr.io/@std/assert/1.0.9/match.js +26 -0
  31. package/esm/deps/jsr.io/@std/assert/1.0.9/not_instance_of.d.ts +20 -0
  32. package/esm/deps/jsr.io/@std/assert/1.0.9/not_instance_of.d.ts.map +1 -0
  33. package/esm/deps/jsr.io/@std/assert/1.0.9/not_instance_of.js +29 -0
  34. package/esm/deps/jsr.io/@std/assert/1.0.9/not_match.d.ts +18 -0
  35. package/esm/deps/jsr.io/@std/assert/1.0.9/not_match.d.ts.map +1 -0
  36. package/esm/deps/jsr.io/@std/assert/1.0.9/not_match.js +26 -0
  37. package/esm/deps/jsr.io/@std/assert/1.0.9/not_strict_equals.d.ts +23 -0
  38. package/esm/deps/jsr.io/@std/assert/1.0.9/not_strict_equals.d.ts.map +1 -0
  39. package/esm/deps/jsr.io/@std/assert/1.0.9/not_strict_equals.js +32 -0
  40. package/esm/deps/jsr.io/@std/assert/1.0.9/rejects.d.ts +42 -0
  41. package/esm/deps/jsr.io/@std/assert/1.0.9/rejects.d.ts.map +1 -0
  42. package/esm/deps/jsr.io/@std/assert/1.0.9/rejects.js +53 -0
  43. package/esm/deps/jsr.io/@std/assert/1.0.9/strict_equals.d.ts +24 -0
  44. package/esm/deps/jsr.io/@std/assert/1.0.9/strict_equals.d.ts.map +1 -0
  45. package/esm/deps/jsr.io/@std/assert/1.0.9/strict_equals.js +57 -0
  46. package/esm/deps/jsr.io/@std/expect/1.0.9/_assert_equals.d.ts +20 -0
  47. package/esm/deps/jsr.io/@std/expect/1.0.9/_assert_equals.d.ts.map +1 -0
  48. package/esm/deps/jsr.io/@std/expect/1.0.9/_assert_equals.js +29 -0
  49. package/esm/deps/jsr.io/@std/expect/1.0.9/_assert_not_equals.d.ts +17 -0
  50. package/esm/deps/jsr.io/@std/expect/1.0.9/_assert_not_equals.d.ts.map +1 -0
  51. package/esm/deps/jsr.io/@std/expect/1.0.9/_assert_not_equals.js +26 -0
  52. package/esm/deps/jsr.io/@std/expect/1.0.9/_assertions.d.ts +4 -0
  53. package/esm/deps/jsr.io/@std/expect/1.0.9/_assertions.d.ts.map +1 -0
  54. package/esm/deps/jsr.io/@std/expect/1.0.9/_assertions.js +13 -0
  55. package/esm/deps/jsr.io/@std/expect/1.0.9/_asymmetric_matchers.d.ts +46 -0
  56. package/esm/deps/jsr.io/@std/expect/1.0.9/_asymmetric_matchers.d.ts.map +1 -0
  57. package/esm/deps/jsr.io/@std/expect/1.0.9/_asymmetric_matchers.js +160 -0
  58. package/esm/deps/jsr.io/@std/expect/1.0.9/_build_message.d.ts +6 -0
  59. package/esm/deps/jsr.io/@std/expect/1.0.9/_build_message.d.ts.map +1 -0
  60. package/esm/deps/jsr.io/@std/expect/1.0.9/_build_message.js +29 -0
  61. package/esm/deps/jsr.io/@std/expect/1.0.9/_custom_equality_tester.d.ts +4 -0
  62. package/esm/deps/jsr.io/@std/expect/1.0.9/_custom_equality_tester.d.ts.map +1 -0
  63. package/esm/deps/jsr.io/@std/expect/1.0.9/_custom_equality_tester.js +11 -0
  64. package/esm/deps/jsr.io/@std/expect/1.0.9/_equal.d.ts +9 -0
  65. package/esm/deps/jsr.io/@std/expect/1.0.9/_equal.d.ts.map +1 -0
  66. package/esm/deps/jsr.io/@std/expect/1.0.9/_equal.js +191 -0
  67. package/esm/deps/jsr.io/@std/expect/1.0.9/_extend.d.ts +4 -0
  68. package/esm/deps/jsr.io/@std/expect/1.0.9/_extend.d.ts.map +1 -0
  69. package/esm/deps/jsr.io/@std/expect/1.0.9/_extend.js +11 -0
  70. package/esm/deps/jsr.io/@std/expect/1.0.9/_inspect_args.d.ts +3 -0
  71. package/esm/deps/jsr.io/@std/expect/1.0.9/_inspect_args.d.ts.map +1 -0
  72. package/esm/deps/jsr.io/@std/expect/1.0.9/_inspect_args.js +12 -0
  73. package/esm/deps/jsr.io/@std/expect/1.0.9/_matchers.d.ts +34 -0
  74. package/esm/deps/jsr.io/@std/expect/1.0.9/_matchers.d.ts.map +1 -0
  75. package/esm/deps/jsr.io/@std/expect/1.0.9/_matchers.js +568 -0
  76. package/esm/deps/jsr.io/@std/expect/1.0.9/_mock_util.d.ts +11 -0
  77. package/esm/deps/jsr.io/@std/expect/1.0.9/_mock_util.d.ts.map +1 -0
  78. package/esm/deps/jsr.io/@std/expect/1.0.9/_mock_util.js +10 -0
  79. package/esm/deps/jsr.io/@std/expect/1.0.9/_serializer.d.ts +4 -0
  80. package/esm/deps/jsr.io/@std/expect/1.0.9/_serializer.d.ts.map +1 -0
  81. package/esm/deps/jsr.io/@std/expect/1.0.9/_serializer.js +10 -0
  82. package/esm/deps/jsr.io/@std/expect/1.0.9/_types.d.ts +839 -0
  83. package/esm/deps/jsr.io/@std/expect/1.0.9/_types.d.ts.map +1 -0
  84. package/esm/deps/jsr.io/@std/expect/1.0.9/_types.js +3 -0
  85. package/esm/deps/jsr.io/@std/expect/1.0.9/_utils.d.ts +9 -0
  86. package/esm/deps/jsr.io/@std/expect/1.0.9/_utils.d.ts.map +1 -0
  87. package/esm/deps/jsr.io/@std/expect/1.0.9/_utils.js +218 -0
  88. package/esm/deps/jsr.io/@std/expect/1.0.9/expect.d.ts +60 -0
  89. package/esm/deps/jsr.io/@std/expect/1.0.9/expect.d.ts.map +1 -0
  90. package/esm/deps/jsr.io/@std/expect/1.0.9/expect.js +523 -0
  91. package/esm/deps/jsr.io/@std/internal/1.0.5/assertion_state.d.ts +160 -0
  92. package/esm/deps/jsr.io/@std/internal/1.0.5/assertion_state.d.ts.map +1 -0
  93. package/esm/deps/jsr.io/@std/internal/1.0.5/assertion_state.js +199 -0
  94. package/esm/deps/jsr.io/@std/internal/1.0.5/build_message.d.ts +82 -0
  95. package/esm/deps/jsr.io/@std/internal/1.0.5/build_message.d.ts.map +1 -0
  96. package/esm/deps/jsr.io/@std/internal/1.0.5/build_message.js +111 -0
  97. package/esm/deps/jsr.io/@std/internal/1.0.5/diff.d.ts +140 -0
  98. package/esm/deps/jsr.io/@std/internal/1.0.5/diff.d.ts.map +1 -0
  99. package/esm/deps/jsr.io/@std/internal/1.0.5/diff.js +277 -0
  100. package/esm/deps/jsr.io/@std/internal/1.0.5/diff_str.d.ts +99 -0
  101. package/esm/deps/jsr.io/@std/internal/1.0.5/diff_str.d.ts.map +1 -0
  102. package/esm/deps/jsr.io/@std/internal/1.0.5/diff_str.js +180 -0
  103. package/esm/deps/jsr.io/@std/internal/1.0.5/format.d.ts +2 -0
  104. package/esm/deps/jsr.io/@std/internal/1.0.5/format.d.ts.map +1 -0
  105. package/esm/deps/jsr.io/@std/internal/1.0.5/format.js +37 -0
  106. package/esm/deps/jsr.io/@std/internal/1.0.5/styles.d.ts +159 -0
  107. package/esm/deps/jsr.io/@std/internal/1.0.5/styles.d.ts.map +1 -0
  108. package/esm/deps/jsr.io/@std/internal/1.0.5/styles.js +207 -0
  109. package/esm/deps/jsr.io/@std/internal/1.0.5/types.d.ts +16 -0
  110. package/esm/deps/jsr.io/@std/internal/1.0.5/types.d.ts.map +1 -0
  111. package/esm/deps/jsr.io/@std/internal/1.0.5/types.js +2 -0
  112. package/esm/deps/jsr.io/@std/testing/1.0.6/_mock_utils.d.ts +15 -0
  113. package/esm/deps/jsr.io/@std/testing/1.0.6/_mock_utils.d.ts.map +1 -0
  114. package/esm/deps/jsr.io/@std/testing/1.0.6/_mock_utils.js +35 -0
  115. package/esm/deps/jsr.io/@std/testing/1.0.6/_test_suite.d.ts +74 -0
  116. package/esm/deps/jsr.io/@std/testing/1.0.6/_test_suite.d.ts.map +1 -0
  117. package/esm/deps/jsr.io/@std/testing/1.0.6/_test_suite.js +350 -0
  118. package/esm/deps/jsr.io/@std/testing/1.0.6/bdd.d.ts +736 -0
  119. package/esm/deps/jsr.io/@std/testing/1.0.6/bdd.d.ts.map +1 -0
  120. package/esm/deps/jsr.io/@std/testing/1.0.6/bdd.js +652 -0
  121. package/esm/deps/jsr.io/@std/testing/1.0.6/mock.d.ts +674 -0
  122. package/esm/deps/jsr.io/@std/testing/1.0.6/mock.d.ts.map +1 -0
  123. package/esm/deps/jsr.io/@std/testing/1.0.6/mock.js +1083 -0
  124. package/esm/src/ast/nodes/annotation.test.d.ts +2 -0
  125. package/esm/src/ast/nodes/annotation.test.d.ts.map +1 -0
  126. package/esm/src/ast/nodes/annotation.test.js +56 -0
  127. package/esm/src/ast/nodes/argument.test.d.ts +2 -0
  128. package/esm/src/ast/nodes/argument.test.d.ts.map +1 -0
  129. package/esm/src/ast/nodes/argument.test.js +33 -0
  130. package/esm/src/ast/nodes/call.test.d.ts +2 -0
  131. package/esm/src/ast/nodes/call.test.d.ts.map +1 -0
  132. package/esm/src/ast/nodes/call.test.js +35 -0
  133. package/esm/src/ast/nodes/class.test.d.ts +2 -0
  134. package/esm/src/ast/nodes/class.test.d.ts.map +1 -0
  135. package/esm/src/ast/nodes/class.test.js +219 -0
  136. package/esm/src/ast/nodes/constructor.test.d.ts +2 -0
  137. package/esm/src/ast/nodes/constructor.test.d.ts.map +1 -0
  138. package/esm/src/ast/nodes/constructor.test.js +139 -0
  139. package/esm/src/ast/nodes/doc-tag.test.d.ts +2 -0
  140. package/esm/src/ast/nodes/doc-tag.test.d.ts.map +1 -0
  141. package/esm/src/ast/nodes/doc-tag.test.js +67 -0
  142. package/esm/src/ast/nodes/doc.test.d.ts +2 -0
  143. package/esm/src/ast/nodes/doc.test.d.ts.map +1 -0
  144. package/esm/src/ast/nodes/doc.test.js +33 -0
  145. package/esm/src/ast/nodes/enum-value.test.d.ts +2 -0
  146. package/esm/src/ast/nodes/enum-value.test.d.ts.map +1 -0
  147. package/esm/src/ast/nodes/enum-value.test.js +115 -0
  148. package/esm/src/ast/nodes/enum.test.d.ts +2 -0
  149. package/esm/src/ast/nodes/enum.test.d.ts.map +1 -0
  150. package/esm/src/ast/nodes/enum.test.js +129 -0
  151. package/esm/src/ast/nodes/function.test.d.ts +2 -0
  152. package/esm/src/ast/nodes/function.test.d.ts.map +1 -0
  153. package/esm/src/ast/nodes/function.test.js +160 -0
  154. package/esm/src/ast/nodes/generic-parameter.test.d.ts +2 -0
  155. package/esm/src/ast/nodes/generic-parameter.test.d.ts.map +1 -0
  156. package/esm/src/ast/nodes/generic-parameter.test.js +49 -0
  157. package/esm/src/ast/nodes/init-block.test.d.ts +2 -0
  158. package/esm/src/ast/nodes/init-block.test.d.ts.map +1 -0
  159. package/esm/src/ast/nodes/init-block.test.js +28 -0
  160. package/esm/src/ast/nodes/interface.test.d.ts +2 -0
  161. package/esm/src/ast/nodes/interface.test.d.ts.map +1 -0
  162. package/esm/src/ast/nodes/interface.test.js +121 -0
  163. package/esm/src/ast/nodes/object.test.d.ts +2 -0
  164. package/esm/src/ast/nodes/object.test.d.ts.map +1 -0
  165. package/esm/src/ast/nodes/object.test.js +78 -0
  166. package/esm/src/ast/nodes/parameter.test.d.ts +2 -0
  167. package/esm/src/ast/nodes/parameter.test.d.ts.map +1 -0
  168. package/esm/src/ast/nodes/parameter.test.js +152 -0
  169. package/esm/src/ast/nodes/property.test.d.ts +2 -0
  170. package/esm/src/ast/nodes/property.test.d.ts.map +1 -0
  171. package/esm/src/ast/nodes/property.test.js +206 -0
  172. package/esm/src/ast/nodes/reference.test.d.ts +2 -0
  173. package/esm/src/ast/nodes/reference.test.d.ts.map +1 -0
  174. package/esm/src/ast/nodes/reference.test.js +36 -0
  175. package/esm/src/ast/nodes/string.test.d.ts +2 -0
  176. package/esm/src/ast/nodes/string.test.d.ts.map +1 -0
  177. package/esm/src/ast/nodes/string.test.js +48 -0
  178. package/esm/src/ast/references/spring.d.ts +0 -1
  179. package/esm/src/ast/references/spring.d.ts.map +1 -1
  180. package/esm/src/ast/references/spring.js +0 -2
  181. package/esm/src/generators/services/okhttp3-clients/okhttp3-client-generator.js +26 -26
  182. package/esm/src/generators/services/spring-controllers/args.d.ts +2 -17
  183. package/esm/src/generators/services/spring-controllers/args.d.ts.map +1 -1
  184. package/esm/src/generators/services/spring-controllers/models.d.ts +1 -2
  185. package/esm/src/generators/services/spring-controllers/models.d.ts.map +1 -1
  186. package/esm/src/generators/services/spring-controllers/models.js +1 -2
  187. package/esm/src/generators/services/spring-controllers/spring-controller-generator.d.ts +2 -4
  188. package/esm/src/generators/services/spring-controllers/spring-controller-generator.d.ts.map +1 -1
  189. package/esm/src/generators/services/spring-controllers/spring-controller-generator.js +17 -78
  190. package/esm/src/import-collection.test.d.ts +2 -0
  191. package/esm/src/import-collection.test.d.ts.map +1 -0
  192. package/esm/src/import-collection.test.js +99 -0
  193. package/esm/tests/openapi-models.test.d.ts +2 -0
  194. package/esm/tests/openapi-models.test.d.ts.map +1 -0
  195. package/esm/tests/openapi-models.test.js +45 -0
  196. package/package.json +1 -2
  197. package/script/_dnt.test_polyfills.d.ts +29 -0
  198. package/script/_dnt.test_polyfills.d.ts.map +1 -0
  199. package/script/_dnt.test_polyfills.js +32 -0
  200. package/script/_dnt.test_shims.d.ts +6 -0
  201. package/script/_dnt.test_shims.d.ts.map +1 -0
  202. package/script/_dnt.test_shims.js +65 -0
  203. package/script/deps/jsr.io/@std/assert/1.0.9/assertion_error.d.ts +26 -0
  204. package/script/deps/jsr.io/@std/assert/1.0.9/assertion_error.d.ts.map +1 -0
  205. package/script/deps/jsr.io/@std/assert/1.0.9/assertion_error.js +34 -0
  206. package/script/deps/jsr.io/@std/assert/1.0.9/equal.d.ts +17 -0
  207. package/script/deps/jsr.io/@std/assert/1.0.9/equal.d.ts.map +1 -0
  208. package/script/deps/jsr.io/@std/assert/1.0.9/equal.js +187 -0
  209. package/script/deps/jsr.io/@std/assert/1.0.9/equals.d.ts +35 -0
  210. package/script/deps/jsr.io/@std/assert/1.0.9/equals.d.ts.map +1 -0
  211. package/script/deps/jsr.io/@std/assert/1.0.9/equals.js +61 -0
  212. package/script/deps/jsr.io/@std/assert/1.0.9/false.d.ts +18 -0
  213. package/script/deps/jsr.io/@std/assert/1.0.9/false.d.ts.map +1 -0
  214. package/script/deps/jsr.io/@std/assert/1.0.9/false.js +25 -0
  215. package/script/deps/jsr.io/@std/assert/1.0.9/instance_of.d.ts +23 -0
  216. package/script/deps/jsr.io/@std/assert/1.0.9/instance_of.d.ts.map +1 -0
  217. package/script/deps/jsr.io/@std/assert/1.0.9/instance_of.js +56 -0
  218. package/script/deps/jsr.io/@std/assert/1.0.9/is_error.d.ts +25 -0
  219. package/script/deps/jsr.io/@std/assert/1.0.9/is_error.d.ts.map +1 -0
  220. package/script/deps/jsr.io/@std/assert/1.0.9/is_error.js +57 -0
  221. package/script/deps/jsr.io/@std/assert/1.0.9/match.d.ts +18 -0
  222. package/script/deps/jsr.io/@std/assert/1.0.9/match.d.ts.map +1 -0
  223. package/script/deps/jsr.io/@std/assert/1.0.9/match.js +29 -0
  224. package/script/deps/jsr.io/@std/assert/1.0.9/not_instance_of.d.ts +20 -0
  225. package/script/deps/jsr.io/@std/assert/1.0.9/not_instance_of.d.ts.map +1 -0
  226. package/script/deps/jsr.io/@std/assert/1.0.9/not_instance_of.js +32 -0
  227. package/script/deps/jsr.io/@std/assert/1.0.9/not_match.d.ts +18 -0
  228. package/script/deps/jsr.io/@std/assert/1.0.9/not_match.d.ts.map +1 -0
  229. package/script/deps/jsr.io/@std/assert/1.0.9/not_match.js +29 -0
  230. package/script/deps/jsr.io/@std/assert/1.0.9/not_strict_equals.d.ts +23 -0
  231. package/script/deps/jsr.io/@std/assert/1.0.9/not_strict_equals.d.ts.map +1 -0
  232. package/script/deps/jsr.io/@std/assert/1.0.9/not_strict_equals.js +35 -0
  233. package/script/deps/jsr.io/@std/assert/1.0.9/rejects.d.ts +42 -0
  234. package/script/deps/jsr.io/@std/assert/1.0.9/rejects.d.ts.map +1 -0
  235. package/script/deps/jsr.io/@std/assert/1.0.9/rejects.js +56 -0
  236. package/script/deps/jsr.io/@std/assert/1.0.9/strict_equals.d.ts +24 -0
  237. package/script/deps/jsr.io/@std/assert/1.0.9/strict_equals.d.ts.map +1 -0
  238. package/script/deps/jsr.io/@std/assert/1.0.9/strict_equals.js +60 -0
  239. package/script/deps/jsr.io/@std/expect/1.0.9/_assert_equals.d.ts +20 -0
  240. package/script/deps/jsr.io/@std/expect/1.0.9/_assert_equals.d.ts.map +1 -0
  241. package/script/deps/jsr.io/@std/expect/1.0.9/_assert_equals.js +32 -0
  242. package/script/deps/jsr.io/@std/expect/1.0.9/_assert_not_equals.d.ts +17 -0
  243. package/script/deps/jsr.io/@std/expect/1.0.9/_assert_not_equals.d.ts.map +1 -0
  244. package/script/deps/jsr.io/@std/expect/1.0.9/_assert_not_equals.js +29 -0
  245. package/script/deps/jsr.io/@std/expect/1.0.9/_assertions.d.ts +4 -0
  246. package/script/deps/jsr.io/@std/expect/1.0.9/_assertions.d.ts.map +1 -0
  247. package/script/deps/jsr.io/@std/expect/1.0.9/_assertions.js +18 -0
  248. package/script/deps/jsr.io/@std/expect/1.0.9/_asymmetric_matchers.d.ts +46 -0
  249. package/script/deps/jsr.io/@std/expect/1.0.9/_asymmetric_matchers.d.ts.map +1 -0
  250. package/script/deps/jsr.io/@std/expect/1.0.9/_asymmetric_matchers.js +182 -0
  251. package/script/deps/jsr.io/@std/expect/1.0.9/_build_message.d.ts +6 -0
  252. package/script/deps/jsr.io/@std/expect/1.0.9/_build_message.d.ts.map +1 -0
  253. package/script/deps/jsr.io/@std/expect/1.0.9/_build_message.js +33 -0
  254. package/script/deps/jsr.io/@std/expect/1.0.9/_custom_equality_tester.d.ts +4 -0
  255. package/script/deps/jsr.io/@std/expect/1.0.9/_custom_equality_tester.d.ts.map +1 -0
  256. package/script/deps/jsr.io/@std/expect/1.0.9/_custom_equality_tester.js +15 -0
  257. package/script/deps/jsr.io/@std/expect/1.0.9/_equal.d.ts +9 -0
  258. package/script/deps/jsr.io/@std/expect/1.0.9/_equal.d.ts.map +1 -0
  259. package/script/deps/jsr.io/@std/expect/1.0.9/_equal.js +194 -0
  260. package/script/deps/jsr.io/@std/expect/1.0.9/_extend.d.ts +4 -0
  261. package/script/deps/jsr.io/@std/expect/1.0.9/_extend.d.ts.map +1 -0
  262. package/script/deps/jsr.io/@std/expect/1.0.9/_extend.js +15 -0
  263. package/script/deps/jsr.io/@std/expect/1.0.9/_inspect_args.d.ts +3 -0
  264. package/script/deps/jsr.io/@std/expect/1.0.9/_inspect_args.d.ts.map +1 -0
  265. package/script/deps/jsr.io/@std/expect/1.0.9/_inspect_args.js +17 -0
  266. package/script/deps/jsr.io/@std/expect/1.0.9/_matchers.d.ts +34 -0
  267. package/script/deps/jsr.io/@std/expect/1.0.9/_matchers.d.ts.map +1 -0
  268. package/script/deps/jsr.io/@std/expect/1.0.9/_matchers.js +602 -0
  269. package/script/deps/jsr.io/@std/expect/1.0.9/_mock_util.d.ts +11 -0
  270. package/script/deps/jsr.io/@std/expect/1.0.9/_mock_util.d.ts.map +1 -0
  271. package/script/deps/jsr.io/@std/expect/1.0.9/_mock_util.js +14 -0
  272. package/script/deps/jsr.io/@std/expect/1.0.9/_serializer.d.ts +4 -0
  273. package/script/deps/jsr.io/@std/expect/1.0.9/_serializer.d.ts.map +1 -0
  274. package/script/deps/jsr.io/@std/expect/1.0.9/_serializer.js +14 -0
  275. package/script/deps/jsr.io/@std/expect/1.0.9/_types.d.ts +839 -0
  276. package/script/deps/jsr.io/@std/expect/1.0.9/_types.d.ts.map +1 -0
  277. package/script/deps/jsr.io/@std/expect/1.0.9/_types.js +4 -0
  278. package/script/deps/jsr.io/@std/expect/1.0.9/_utils.d.ts +9 -0
  279. package/script/deps/jsr.io/@std/expect/1.0.9/_utils.d.ts.map +1 -0
  280. package/script/deps/jsr.io/@std/expect/1.0.9/_utils.js +226 -0
  281. package/script/deps/jsr.io/@std/expect/1.0.9/expect.d.ts +60 -0
  282. package/script/deps/jsr.io/@std/expect/1.0.9/expect.d.ts.map +1 -0
  283. package/script/deps/jsr.io/@std/expect/1.0.9/expect.js +527 -0
  284. package/script/deps/jsr.io/@std/internal/1.0.5/assertion_state.d.ts +160 -0
  285. package/script/deps/jsr.io/@std/internal/1.0.5/assertion_state.d.ts.map +1 -0
  286. package/script/deps/jsr.io/@std/internal/1.0.5/assertion_state.js +204 -0
  287. package/script/deps/jsr.io/@std/internal/1.0.5/build_message.d.ts +82 -0
  288. package/script/deps/jsr.io/@std/internal/1.0.5/build_message.d.ts.map +1 -0
  289. package/script/deps/jsr.io/@std/internal/1.0.5/build_message.js +116 -0
  290. package/script/deps/jsr.io/@std/internal/1.0.5/diff.d.ts +140 -0
  291. package/script/deps/jsr.io/@std/internal/1.0.5/diff.d.ts.map +1 -0
  292. package/script/deps/jsr.io/@std/internal/1.0.5/diff.js +284 -0
  293. package/script/deps/jsr.io/@std/internal/1.0.5/diff_str.d.ts +99 -0
  294. package/script/deps/jsr.io/@std/internal/1.0.5/diff_str.d.ts.map +1 -0
  295. package/script/deps/jsr.io/@std/internal/1.0.5/diff_str.js +186 -0
  296. package/script/deps/jsr.io/@std/internal/1.0.5/format.d.ts +2 -0
  297. package/script/deps/jsr.io/@std/internal/1.0.5/format.d.ts.map +1 -0
  298. package/script/deps/jsr.io/@std/internal/1.0.5/format.js +41 -0
  299. package/script/deps/jsr.io/@std/internal/1.0.5/styles.d.ts +159 -0
  300. package/script/deps/jsr.io/@std/internal/1.0.5/styles.d.ts.map +1 -0
  301. package/script/deps/jsr.io/@std/internal/1.0.5/styles.js +220 -0
  302. package/script/deps/jsr.io/@std/internal/1.0.5/types.d.ts +16 -0
  303. package/script/deps/jsr.io/@std/internal/1.0.5/types.d.ts.map +1 -0
  304. package/script/deps/jsr.io/@std/internal/1.0.5/types.js +3 -0
  305. package/script/deps/jsr.io/@std/testing/1.0.6/_mock_utils.d.ts +15 -0
  306. package/script/deps/jsr.io/@std/testing/1.0.6/_mock_utils.d.ts.map +1 -0
  307. package/script/deps/jsr.io/@std/testing/1.0.6/_mock_utils.js +41 -0
  308. package/script/deps/jsr.io/@std/testing/1.0.6/_test_suite.d.ts +74 -0
  309. package/script/deps/jsr.io/@std/testing/1.0.6/_test_suite.d.ts.map +1 -0
  310. package/script/deps/jsr.io/@std/testing/1.0.6/_test_suite.js +355 -0
  311. package/script/deps/jsr.io/@std/testing/1.0.6/bdd.d.ts +736 -0
  312. package/script/deps/jsr.io/@std/testing/1.0.6/bdd.d.ts.map +1 -0
  313. package/script/deps/jsr.io/@std/testing/1.0.6/bdd.js +663 -0
  314. package/script/deps/jsr.io/@std/testing/1.0.6/mock.d.ts +674 -0
  315. package/script/deps/jsr.io/@std/testing/1.0.6/mock.d.ts.map +1 -0
  316. package/script/deps/jsr.io/@std/testing/1.0.6/mock.js +1102 -0
  317. package/script/src/ast/nodes/annotation.test.d.ts +2 -0
  318. package/script/src/ast/nodes/annotation.test.d.ts.map +1 -0
  319. package/script/src/ast/nodes/annotation.test.js +58 -0
  320. package/script/src/ast/nodes/argument.test.d.ts +2 -0
  321. package/script/src/ast/nodes/argument.test.d.ts.map +1 -0
  322. package/script/src/ast/nodes/argument.test.js +35 -0
  323. package/script/src/ast/nodes/call.test.d.ts +2 -0
  324. package/script/src/ast/nodes/call.test.d.ts.map +1 -0
  325. package/script/src/ast/nodes/call.test.js +37 -0
  326. package/script/src/ast/nodes/class.test.d.ts +2 -0
  327. package/script/src/ast/nodes/class.test.d.ts.map +1 -0
  328. package/script/src/ast/nodes/class.test.js +221 -0
  329. package/script/src/ast/nodes/constructor.test.d.ts +2 -0
  330. package/script/src/ast/nodes/constructor.test.d.ts.map +1 -0
  331. package/script/src/ast/nodes/constructor.test.js +141 -0
  332. package/script/src/ast/nodes/doc-tag.test.d.ts +2 -0
  333. package/script/src/ast/nodes/doc-tag.test.d.ts.map +1 -0
  334. package/script/src/ast/nodes/doc-tag.test.js +69 -0
  335. package/script/src/ast/nodes/doc.test.d.ts +2 -0
  336. package/script/src/ast/nodes/doc.test.d.ts.map +1 -0
  337. package/script/src/ast/nodes/doc.test.js +35 -0
  338. package/script/src/ast/nodes/enum-value.test.d.ts +2 -0
  339. package/script/src/ast/nodes/enum-value.test.d.ts.map +1 -0
  340. package/script/src/ast/nodes/enum-value.test.js +117 -0
  341. package/script/src/ast/nodes/enum.test.d.ts +2 -0
  342. package/script/src/ast/nodes/enum.test.d.ts.map +1 -0
  343. package/script/src/ast/nodes/enum.test.js +131 -0
  344. package/script/src/ast/nodes/function.test.d.ts +2 -0
  345. package/script/src/ast/nodes/function.test.d.ts.map +1 -0
  346. package/script/src/ast/nodes/function.test.js +162 -0
  347. package/script/src/ast/nodes/generic-parameter.test.d.ts +2 -0
  348. package/script/src/ast/nodes/generic-parameter.test.d.ts.map +1 -0
  349. package/script/src/ast/nodes/generic-parameter.test.js +51 -0
  350. package/script/src/ast/nodes/init-block.test.d.ts +2 -0
  351. package/script/src/ast/nodes/init-block.test.d.ts.map +1 -0
  352. package/script/src/ast/nodes/init-block.test.js +30 -0
  353. package/script/src/ast/nodes/interface.test.d.ts +2 -0
  354. package/script/src/ast/nodes/interface.test.d.ts.map +1 -0
  355. package/script/src/ast/nodes/interface.test.js +123 -0
  356. package/script/src/ast/nodes/object.test.d.ts +2 -0
  357. package/script/src/ast/nodes/object.test.d.ts.map +1 -0
  358. package/script/src/ast/nodes/object.test.js +80 -0
  359. package/script/src/ast/nodes/parameter.test.d.ts +2 -0
  360. package/script/src/ast/nodes/parameter.test.d.ts.map +1 -0
  361. package/script/src/ast/nodes/parameter.test.js +154 -0
  362. package/script/src/ast/nodes/property.test.d.ts +2 -0
  363. package/script/src/ast/nodes/property.test.d.ts.map +1 -0
  364. package/script/src/ast/nodes/property.test.js +208 -0
  365. package/script/src/ast/nodes/reference.test.d.ts +2 -0
  366. package/script/src/ast/nodes/reference.test.d.ts.map +1 -0
  367. package/script/src/ast/nodes/reference.test.js +38 -0
  368. package/script/src/ast/nodes/string.test.d.ts +2 -0
  369. package/script/src/ast/nodes/string.test.d.ts.map +1 -0
  370. package/script/src/ast/nodes/string.test.js +50 -0
  371. package/script/src/ast/references/spring.d.ts +0 -1
  372. package/script/src/ast/references/spring.d.ts.map +1 -1
  373. package/script/src/ast/references/spring.js +1 -3
  374. package/script/src/generators/services/okhttp3-clients/okhttp3-client-generator.js +26 -26
  375. package/script/src/generators/services/spring-controllers/args.d.ts +2 -17
  376. package/script/src/generators/services/spring-controllers/args.d.ts.map +1 -1
  377. package/script/src/generators/services/spring-controllers/models.d.ts +1 -2
  378. package/script/src/generators/services/spring-controllers/models.d.ts.map +1 -1
  379. package/script/src/generators/services/spring-controllers/models.js +1 -2
  380. package/script/src/generators/services/spring-controllers/spring-controller-generator.d.ts +2 -4
  381. package/script/src/generators/services/spring-controllers/spring-controller-generator.d.ts.map +1 -1
  382. package/script/src/generators/services/spring-controllers/spring-controller-generator.js +18 -79
  383. package/script/src/import-collection.test.d.ts +2 -0
  384. package/script/src/import-collection.test.d.ts.map +1 -0
  385. package/script/src/import-collection.test.js +101 -0
  386. package/script/tests/openapi-models.test.d.ts +2 -0
  387. package/script/tests/openapi-models.test.d.ts.map +1 -0
  388. package/script/tests/openapi-models.test.js +48 -0
  389. package/src/_dnt.test_polyfills.ts +70 -0
  390. package/src/_dnt.test_shims.ts +64 -0
  391. package/src/deps/jsr.io/@std/assert/1.0.9/assertion_error.ts +31 -0
  392. package/src/deps/jsr.io/@std/assert/1.0.9/equal.ts +210 -0
  393. package/src/deps/jsr.io/@std/assert/1.0.9/equals.ts +65 -0
  394. package/src/deps/jsr.io/@std/assert/1.0.9/false.ts +26 -0
  395. package/src/deps/jsr.io/@std/assert/1.0.9/instance_of.ts +64 -0
  396. package/src/deps/jsr.io/@std/assert/1.0.9/is_error.ts +65 -0
  397. package/src/deps/jsr.io/@std/assert/1.0.9/match.ts +30 -0
  398. package/src/deps/jsr.io/@std/assert/1.0.9/not_instance_of.ts +33 -0
  399. package/src/deps/jsr.io/@std/assert/1.0.9/not_match.ts +30 -0
  400. package/src/deps/jsr.io/@std/assert/1.0.9/not_strict_equals.ts +42 -0
  401. package/src/deps/jsr.io/@std/assert/1.0.9/rejects.ts +123 -0
  402. package/src/deps/jsr.io/@std/assert/1.0.9/strict_equals.ts +67 -0
  403. package/src/deps/jsr.io/@std/expect/1.0.9/_assert_equals.ts +38 -0
  404. package/src/deps/jsr.io/@std/expect/1.0.9/_assert_not_equals.ts +35 -0
  405. package/src/deps/jsr.io/@std/expect/1.0.9/_assertions.ts +18 -0
  406. package/src/deps/jsr.io/@std/expect/1.0.9/_asymmetric_matchers.ts +193 -0
  407. package/src/deps/jsr.io/@std/expect/1.0.9/_build_message.ts +51 -0
  408. package/src/deps/jsr.io/@std/expect/1.0.9/_custom_equality_tester.ts +19 -0
  409. package/src/deps/jsr.io/@std/expect/1.0.9/_equal.ts +230 -0
  410. package/src/deps/jsr.io/@std/expect/1.0.9/_extend.ts +16 -0
  411. package/src/deps/jsr.io/@std/expect/1.0.9/_inspect_args.ts +15 -0
  412. package/src/deps/jsr.io/@std/expect/1.0.9/_matchers.ts +838 -0
  413. package/src/deps/jsr.io/@std/expect/1.0.9/_mock_util.ts +22 -0
  414. package/src/deps/jsr.io/@std/expect/1.0.9/_serializer.ts +15 -0
  415. package/src/deps/jsr.io/@std/expect/1.0.9/_types.ts +919 -0
  416. package/src/deps/jsr.io/@std/expect/1.0.9/_utils.ts +283 -0
  417. package/src/deps/jsr.io/@std/expect/1.0.9/expect.ts +620 -0
  418. package/src/deps/jsr.io/@std/internal/1.0.5/assertion_state.ts +214 -0
  419. package/src/deps/jsr.io/@std/internal/1.0.5/build_message.ts +134 -0
  420. package/src/deps/jsr.io/@std/internal/1.0.5/diff.ts +317 -0
  421. package/src/deps/jsr.io/@std/internal/1.0.5/diff_str.ts +204 -0
  422. package/src/deps/jsr.io/@std/internal/1.0.5/format.ts +39 -0
  423. package/src/deps/jsr.io/@std/internal/1.0.5/styles.ts +233 -0
  424. package/src/deps/jsr.io/@std/internal/1.0.5/types.ts +18 -0
  425. package/src/deps/jsr.io/@std/testing/1.0.6/_mock_utils.ts +43 -0
  426. package/src/deps/jsr.io/@std/testing/1.0.6/_test_suite.ts +410 -0
  427. package/src/deps/jsr.io/@std/testing/1.0.6/bdd.ts +1285 -0
  428. package/src/deps/jsr.io/@std/testing/1.0.6/mock.ts +1807 -0
  429. package/src/mod.ts +8 -0
  430. package/src/src/assets.ts +9 -0
  431. package/src/src/ast/_index.ts +66 -0
  432. package/src/src/ast/common.ts +1 -0
  433. package/src/src/ast/index.ts +1 -0
  434. package/src/src/ast/node.ts +10 -0
  435. package/src/src/ast/nodes/annotation.test.ts +69 -0
  436. package/src/src/ast/nodes/annotation.ts +79 -0
  437. package/src/src/ast/nodes/argument.test.ts +41 -0
  438. package/src/src/ast/nodes/argument.ts +62 -0
  439. package/src/src/ast/nodes/call.test.ts +44 -0
  440. package/src/src/ast/nodes/call.ts +66 -0
  441. package/src/src/ast/nodes/class.test.ts +274 -0
  442. package/src/src/ast/nodes/class.ts +178 -0
  443. package/src/src/ast/nodes/collection-literal.ts +49 -0
  444. package/src/src/ast/nodes/constructor.test.ts +178 -0
  445. package/src/src/ast/nodes/constructor.ts +126 -0
  446. package/src/src/ast/nodes/doc-tag.test.ts +84 -0
  447. package/src/src/ast/nodes/doc-tag.ts +138 -0
  448. package/src/src/ast/nodes/doc.test.ts +42 -0
  449. package/src/src/ast/nodes/doc.ts +111 -0
  450. package/src/src/ast/nodes/enum-value.test.ts +146 -0
  451. package/src/src/ast/nodes/enum-value.ts +100 -0
  452. package/src/src/ast/nodes/enum.test.ts +167 -0
  453. package/src/src/ast/nodes/enum.ts +163 -0
  454. package/src/src/ast/nodes/function.test.ts +194 -0
  455. package/src/src/ast/nodes/function.ts +176 -0
  456. package/src/src/ast/nodes/generic-parameter.test.ts +60 -0
  457. package/src/src/ast/nodes/generic-parameter.ts +54 -0
  458. package/src/src/ast/nodes/init-block.test.ts +36 -0
  459. package/src/src/ast/nodes/init-block.ts +38 -0
  460. package/src/src/ast/nodes/interface.test.ts +151 -0
  461. package/src/src/ast/nodes/interface.ts +133 -0
  462. package/src/src/ast/nodes/lambda-type.ts +68 -0
  463. package/src/src/ast/nodes/lambda.ts +68 -0
  464. package/src/src/ast/nodes/object.test.ts +101 -0
  465. package/src/src/ast/nodes/object.ts +102 -0
  466. package/src/src/ast/nodes/parameter.test.ts +191 -0
  467. package/src/src/ast/nodes/parameter.ts +118 -0
  468. package/src/src/ast/nodes/property.test.ts +253 -0
  469. package/src/src/ast/nodes/property.ts +225 -0
  470. package/src/src/ast/nodes/reference.test.ts +47 -0
  471. package/src/src/ast/nodes/reference.ts +178 -0
  472. package/src/src/ast/nodes/string.test.ts +61 -0
  473. package/src/src/ast/nodes/string.ts +114 -0
  474. package/src/src/ast/nodes/types.ts +23 -0
  475. package/src/src/ast/references/index.ts +8 -0
  476. package/src/src/ast/references/jackson.ts +16 -0
  477. package/src/src/ast/references/jakarta.ts +10 -0
  478. package/src/src/ast/references/java.ts +19 -0
  479. package/src/src/ast/references/kotlin.ts +40 -0
  480. package/src/src/ast/references/okhttp3.ts +5 -0
  481. package/src/src/ast/references/reactor.ts +5 -0
  482. package/src/src/ast/references/spring.ts +58 -0
  483. package/src/src/ast/references/swagger.ts +23 -0
  484. package/src/src/ast/utils/get-kotlin-builder-options.ts +19 -0
  485. package/src/src/ast/utils/to-kt-node.ts +31 -0
  486. package/src/src/ast/utils/write-kt-annotations.ts +15 -0
  487. package/src/src/ast/utils/write-kt-arguments.ts +45 -0
  488. package/src/src/ast/utils/write-kt-enum-values.ts +27 -0
  489. package/src/src/ast/utils/write-kt-generic-parameters.ts +12 -0
  490. package/src/src/ast/utils/write-kt-members.ts +25 -0
  491. package/src/src/ast/utils/write-kt-node.ts +37 -0
  492. package/src/src/ast/utils/write-kt-parameters.ts +25 -0
  493. package/src/src/common-results.ts +4 -0
  494. package/src/src/config.ts +41 -0
  495. package/src/src/file-builder.ts +108 -0
  496. package/src/src/generators/file-generator.ts +29 -0
  497. package/src/src/generators/index.ts +4 -0
  498. package/src/src/generators/models/args.ts +128 -0
  499. package/src/src/generators/models/index.ts +4 -0
  500. package/src/src/generators/models/model-generator.ts +602 -0
  501. package/src/src/generators/models/models-generator.ts +65 -0
  502. package/src/src/generators/models/models.ts +95 -0
  503. package/src/src/generators/services/okhttp3-clients/args.ts +78 -0
  504. package/src/src/generators/services/okhttp3-clients/index.ts +4 -0
  505. package/src/src/generators/services/okhttp3-clients/models.ts +62 -0
  506. package/src/src/generators/services/okhttp3-clients/okhttp3-client-generator.ts +557 -0
  507. package/src/src/generators/services/okhttp3-clients/okhttp3-clients-generator.ts +130 -0
  508. package/src/src/generators/services/okhttp3-clients/refs.ts +55 -0
  509. package/src/src/generators/services/spring-controllers/args.ts +73 -0
  510. package/src/src/generators/services/spring-controllers/index.ts +4 -0
  511. package/src/src/generators/services/spring-controllers/models.ts +60 -0
  512. package/src/src/generators/services/spring-controllers/spring-controller-generator.ts +659 -0
  513. package/src/src/generators/services/spring-controllers/spring-controllers-generator.ts +70 -0
  514. package/src/src/import-collection.test.ts +116 -0
  515. package/src/src/import-collection.ts +98 -0
  516. package/src/src/types.ts +3 -0
  517. package/src/src/utils.ts +39 -0
  518. package/src/tests/openapi-models.test.ts +63 -0
  519. package/test_runner.js +227 -0
@@ -0,0 +1,1285 @@
1
+ // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
2
+
3
+ /**
4
+ * A {@link https://en.wikipedia.org/wiki/Behavior-driven_development | BDD} interface
5
+ * to `Deno.test()` API.
6
+ *
7
+ * With `@std/testing/bdd` module you can write your tests in a familiar format for
8
+ * grouping tests and adding setup/teardown hooks used by other JavaScript testing
9
+ * frameworks like Jasmine, Jest, and Mocha.
10
+ *
11
+ * The `describe` function creates a block that groups together several related
12
+ * tests. The `it` function registers an individual test case.
13
+ *
14
+ * ## Hooks
15
+ *
16
+ * There are 4 types of hooks available for test suites. A test suite can have
17
+ * multiples of each type of hook, they will be called in the order that they are
18
+ * registered. The `afterEach` and `afterAll` hooks will be called whether or not
19
+ * the test case passes. The *All hooks will be called once for the whole group
20
+ * while the *Each hooks will be called for each individual test case.
21
+ *
22
+ * - `beforeAll`: Runs before all of the tests in the test suite.
23
+ * - `afterAll`: Runs after all of the tests in the test suite finish.
24
+ * - `beforeEach`: Runs before each of the individual test cases in the test suite.
25
+ * - `afterEach`: Runs after each of the individual test cases in the test suite.
26
+ *
27
+ * If a hook is registered at the top level, a global test suite will be registered
28
+ * and all tests will belong to it. Hooks registered at the top level must be
29
+ * registered before any individual test cases or test suites.
30
+ *
31
+ * ## Focusing tests
32
+ *
33
+ * If you would like to run only specific test cases, you can do so by calling
34
+ * `it.only` instead of `it`. If you would like to run only specific test suites,
35
+ * you can do so by calling `describe.only` instead of `describe`.
36
+ *
37
+ * There is one limitation to this when using the flat test grouping style. When
38
+ * `describe` is called without being nested, it registers the test with
39
+ * `Deno.test`. If a child test case or suite is registered with `it.only` or
40
+ * `describe.only`, it will be scoped to the top test suite instead of the file. To
41
+ * make them the only tests that run in the file, you would need to register the
42
+ * top test suite with `describe.only` too.
43
+ *
44
+ * ## Ignoring tests
45
+ *
46
+ * If you would like to not run specific individual test cases, you can do so by
47
+ * calling `it.ignore` instead of `it`. If you would like to not run specific test
48
+ * suites, you can do so by calling `describe.ignore` instead of `describe`.
49
+ *
50
+ * ## Sanitization options
51
+ *
52
+ * Like `Deno.TestDefinition`, the `DescribeDefinition` and `ItDefinition` have
53
+ * sanitization options. They work in the same way.
54
+ *
55
+ * - `sanitizeExit`: Ensure the test case does not prematurely cause the process to
56
+ * exit, for example via a call to Deno.exit. Defaults to true.
57
+ * - `sanitizeOps`: Check that the number of async completed ops after the test is
58
+ * the same as number of dispatched ops. Defaults to true.
59
+ * - `sanitizeResources`: Ensure the test case does not "leak" resources - ie. the
60
+ * resource table after the test has exactly the same contents as before the
61
+ * test. Defaults to true.
62
+ *
63
+ * ## Permissions option
64
+ *
65
+ * Like `Deno.TestDefinition`, the `DescribeDefinition` and `ItDefinition` have a
66
+ * `permissions` option. They specify the permissions that should be used to run an
67
+ * individual test case or test suite. Set this to `"inherit"` to keep the calling
68
+ * thread's permissions. Set this to `"none"` to revoke all permissions.
69
+ *
70
+ * This setting defaults to `"inherit"`.
71
+ *
72
+ * There is currently one limitation to this, you cannot use the permissions option
73
+ * on an individual test case or test suite that belongs to another test suite.
74
+ * That's because internally those tests are registered with `t.step` which does
75
+ * not support the permissions option.
76
+ *
77
+ * ## Comparing to Deno\.test
78
+ *
79
+ * The default way of writing tests is using `Deno.test` and `t.step`. The
80
+ * `describe` and `it` functions have similar call signatures to `Deno.test`,
81
+ * making it easy to switch between the default style and the behavior-driven
82
+ * development style of writing tests. Internally, `describe` and `it` are
83
+ * registering tests with `Deno.test` and `t.step`.
84
+ *
85
+ * Below is an example of a test file using `Deno.test` and `t.step`. In the
86
+ * following sections there are examples of how the same test could be written with
87
+ * `describe` and `it` using nested test grouping, flat test grouping, or a mix of
88
+ * both styles.
89
+ *
90
+ * ```ts
91
+ * import {
92
+ * assertEquals,
93
+ * assertStrictEquals,
94
+ * assertThrows,
95
+ * } from "@std/assert";
96
+ *
97
+ * class User {
98
+ * static users: Map<string, User> = new Map();
99
+ * name: string;
100
+ * age?: number;
101
+ *
102
+ * constructor(name: string) {
103
+ * if (User.users.has(name)) {
104
+ * throw new Deno.errors.AlreadyExists(`User ${name} already exists`);
105
+ * }
106
+ * this.name = name;
107
+ * User.users.set(name, this);
108
+ * }
109
+ *
110
+ * getAge(): number {
111
+ * if (!this.age) {
112
+ * throw new Error("Age unknown");
113
+ * }
114
+ * return this.age;
115
+ * }
116
+ *
117
+ * setAge(age: number) {
118
+ * this.age = age;
119
+ * }
120
+ * }
121
+ *
122
+ * Deno.test("User.users initially empty", () => {
123
+ * assertEquals(User.users.size, 0);
124
+ * });
125
+ *
126
+ * Deno.test("User constructor", () => {
127
+ * try {
128
+ * const user = new User("Kyle");
129
+ * assertEquals(user.name, "Kyle");
130
+ * assertStrictEquals(User.users.get("Kyle"), user);
131
+ * } finally {
132
+ * User.users.clear();
133
+ * }
134
+ * });
135
+ *
136
+ * Deno.test("User age", async (t) => {
137
+ * const user = new User("Kyle");
138
+ *
139
+ * await t.step("getAge", () => {
140
+ * assertThrows(() => user.getAge(), Error, "Age unknown");
141
+ * user.age = 18;
142
+ * assertEquals(user.getAge(), 18);
143
+ * });
144
+ *
145
+ * await t.step("setAge", () => {
146
+ * user.setAge(18);
147
+ * assertEquals(user.getAge(), 18);
148
+ * });
149
+ * });
150
+ * ```
151
+ *
152
+ * ### Nested test grouping
153
+ *
154
+ * Tests created within the callback of a `describe` function call will belong to
155
+ * the new test suite it creates. The hooks can be created within it or be added to
156
+ * the options argument for describe.
157
+ *
158
+ * ```ts
159
+ * import {
160
+ * assertEquals,
161
+ * assertStrictEquals,
162
+ * assertThrows,
163
+ * } from "@std/assert";
164
+ * import {
165
+ * afterEach,
166
+ * beforeEach,
167
+ * describe,
168
+ * it,
169
+ * } from "@std/testing/bdd";
170
+ *
171
+ * class User {
172
+ * static users: Map<string, User> = new Map();
173
+ * name: string;
174
+ * age?: number;
175
+ *
176
+ * constructor(name: string) {
177
+ * if (User.users.has(name)) {
178
+ * throw new Deno.errors.AlreadyExists(`User ${name} already exists`);
179
+ * }
180
+ * this.name = name;
181
+ * User.users.set(name, this);
182
+ * }
183
+ *
184
+ * getAge(): number {
185
+ * if (!this.age) {
186
+ * throw new Error("Age unknown");
187
+ * }
188
+ * return this.age;
189
+ * }
190
+ *
191
+ * setAge(age: number) {
192
+ * this.age = age;
193
+ * }
194
+ * }
195
+ *
196
+ * describe("User", () => {
197
+ * it("users initially empty", () => {
198
+ * assertEquals(User.users.size, 0);
199
+ * });
200
+ *
201
+ * it("constructor", () => {
202
+ * try {
203
+ * const user = new User("Kyle");
204
+ * assertEquals(user.name, "Kyle");
205
+ * assertStrictEquals(User.users.get("Kyle"), user);
206
+ * } finally {
207
+ * User.users.clear();
208
+ * }
209
+ * });
210
+ *
211
+ * describe("age", () => {
212
+ * let user: User;
213
+ *
214
+ * beforeEach(() => {
215
+ * user = new User("Kyle");
216
+ * });
217
+ *
218
+ * afterEach(() => {
219
+ * User.users.clear();
220
+ * });
221
+ *
222
+ * it("getAge", function () {
223
+ * assertThrows(() => user.getAge(), Error, "Age unknown");
224
+ * user.age = 18;
225
+ * assertEquals(user.getAge(), 18);
226
+ * });
227
+ *
228
+ * it("setAge", function () {
229
+ * user.setAge(18);
230
+ * assertEquals(user.getAge(), 18);
231
+ * });
232
+ * });
233
+ * });
234
+ * ```
235
+ *
236
+ * ### Flat test grouping
237
+ *
238
+ * The `describe` function returns a unique symbol that can be used to reference
239
+ * the test suite for adding tests to it without having to create them within a
240
+ * callback. The gives you the ability to have test grouping without any extra
241
+ * indentation in front of the grouped tests.
242
+ *
243
+ * ```ts
244
+ * import {
245
+ * assertEquals,
246
+ * assertStrictEquals,
247
+ * assertThrows,
248
+ * } from "@std/assert";
249
+ * import {
250
+ * describe,
251
+ * it,
252
+ * } from "@std/testing/bdd";
253
+ *
254
+ * class User {
255
+ * static users: Map<string, User> = new Map();
256
+ * name: string;
257
+ * age?: number;
258
+ *
259
+ * constructor(name: string) {
260
+ * if (User.users.has(name)) {
261
+ * throw new Deno.errors.AlreadyExists(`User ${name} already exists`);
262
+ * }
263
+ * this.name = name;
264
+ * User.users.set(name, this);
265
+ * }
266
+ *
267
+ * getAge(): number {
268
+ * if (!this.age) {
269
+ * throw new Error("Age unknown");
270
+ * }
271
+ * return this.age;
272
+ * }
273
+ *
274
+ * setAge(age: number) {
275
+ * this.age = age;
276
+ * }
277
+ * }
278
+ *
279
+ * const userTests = describe("User");
280
+ *
281
+ * it(userTests, "users initially empty", () => {
282
+ * assertEquals(User.users.size, 0);
283
+ * });
284
+ *
285
+ * it(userTests, "constructor", () => {
286
+ * try {
287
+ * const user = new User("Kyle");
288
+ * assertEquals(user.name, "Kyle");
289
+ * assertStrictEquals(User.users.get("Kyle"), user);
290
+ * } finally {
291
+ * User.users.clear();
292
+ * }
293
+ * });
294
+ *
295
+ * const ageTests = describe({
296
+ * name: "age",
297
+ * suite: userTests,
298
+ * beforeEach(this: { user: User }) {
299
+ * this.user = new User("Kyle");
300
+ * },
301
+ * afterEach() {
302
+ * User.users.clear();
303
+ * },
304
+ * });
305
+ *
306
+ * it(ageTests, "getAge", function () {
307
+ * const { user } = this;
308
+ * assertThrows(() => user.getAge(), Error, "Age unknown");
309
+ * user.age = 18;
310
+ * assertEquals(user.getAge(), 18);
311
+ * });
312
+ *
313
+ * it(ageTests, "setAge", function () {
314
+ * const { user } = this;
315
+ * user.setAge(18);
316
+ * assertEquals(user.getAge(), 18);
317
+ * });
318
+ * ```
319
+ *
320
+ * ### Mixed test grouping
321
+ *
322
+ * Both nested test grouping and flat test grouping can be used together. This can
323
+ * be useful if you'd like to create deep groupings without all the extra
324
+ * indentation in front of each line.
325
+ *
326
+ * ```ts
327
+ * import {
328
+ * assertEquals,
329
+ * assertStrictEquals,
330
+ * assertThrows,
331
+ * } from "@std/assert";
332
+ * import {
333
+ * describe,
334
+ * it,
335
+ * } from "@std/testing/bdd";
336
+ *
337
+ * class User {
338
+ * static users: Map<string, User> = new Map();
339
+ * name: string;
340
+ * age?: number;
341
+ *
342
+ * constructor(name: string) {
343
+ * if (User.users.has(name)) {
344
+ * throw new Deno.errors.AlreadyExists(`User ${name} already exists`);
345
+ * }
346
+ * this.name = name;
347
+ * User.users.set(name, this);
348
+ * }
349
+ *
350
+ * getAge(): number {
351
+ * if (!this.age) {
352
+ * throw new Error("Age unknown");
353
+ * }
354
+ * return this.age;
355
+ * }
356
+ *
357
+ * setAge(age: number) {
358
+ * this.age = age;
359
+ * }
360
+ * }
361
+ *
362
+ * describe("User", () => {
363
+ * it("users initially empty", () => {
364
+ * assertEquals(User.users.size, 0);
365
+ * });
366
+ *
367
+ * it("constructor", () => {
368
+ * try {
369
+ * const user = new User("Kyle");
370
+ * assertEquals(user.name, "Kyle");
371
+ * assertStrictEquals(User.users.get("Kyle"), user);
372
+ * } finally {
373
+ * User.users.clear();
374
+ * }
375
+ * });
376
+ *
377
+ * const ageTests = describe({
378
+ * name: "age",
379
+ * beforeEach(this: { user: User }) {
380
+ * this.user = new User("Kyle");
381
+ * },
382
+ * afterEach() {
383
+ * User.users.clear();
384
+ * },
385
+ * });
386
+ *
387
+ * it(ageTests, "getAge", function () {
388
+ * const { user } = this;
389
+ * assertThrows(() => user.getAge(), Error, "Age unknown");
390
+ * user.age = 18;
391
+ * assertEquals(user.getAge(), 18);
392
+ * });
393
+ *
394
+ * it(ageTests, "setAge", function () {
395
+ * const { user } = this;
396
+ * user.setAge(18);
397
+ * assertEquals(user.getAge(), 18);
398
+ * });
399
+ * });
400
+ * ```
401
+ *
402
+ * @module
403
+ */
404
+ import * as dntShim from "../../../../../_dnt.test_shims.js";
405
+
406
+
407
+ import { getAssertionState } from "../../internal/1.0.5/assertion_state.js";
408
+ import { AssertionError } from "../../assert/1.0.9/assertion_error.js";
409
+ import {
410
+ type DescribeDefinition,
411
+ type HookNames,
412
+ type ItDefinition,
413
+ type TestSuite,
414
+ TestSuiteInternal,
415
+ } from "./_test_suite.js";
416
+ export type { DescribeDefinition, ItDefinition, TestSuite };
417
+
418
+ /** The arguments for an ItFunction. */
419
+ export type ItArgs<T> =
420
+ | [options: ItDefinition<T>]
421
+ | [
422
+ name: string,
423
+ options: Omit<ItDefinition<T>, "name">,
424
+ ]
425
+ | [
426
+ name: string,
427
+ fn: (this: T, t: dntShim.Deno.TestContext) => void | Promise<void>,
428
+ ]
429
+ | [fn: (this: T, t: dntShim.Deno.TestContext) => void | Promise<void>]
430
+ | [
431
+ name: string,
432
+ options: Omit<ItDefinition<T>, "fn" | "name">,
433
+ fn: (this: T, t: dntShim.Deno.TestContext) => void | Promise<void>,
434
+ ]
435
+ | [
436
+ options: Omit<ItDefinition<T>, "fn">,
437
+ fn: (this: T, t: dntShim.Deno.TestContext) => void | Promise<void>,
438
+ ]
439
+ | [
440
+ options: Omit<ItDefinition<T>, "fn" | "name">,
441
+ fn: (this: T, t: dntShim.Deno.TestContext) => void | Promise<void>,
442
+ ]
443
+ | [
444
+ suite: TestSuite<T>,
445
+ name: string,
446
+ options: Omit<ItDefinition<T>, "name" | "suite">,
447
+ ]
448
+ | [
449
+ suite: TestSuite<T>,
450
+ name: string,
451
+ fn: (this: T, t: dntShim.Deno.TestContext) => void | Promise<void>,
452
+ ]
453
+ | [
454
+ suite: TestSuite<T>,
455
+ fn: (this: T, t: dntShim.Deno.TestContext) => void | Promise<void>,
456
+ ]
457
+ | [
458
+ suite: TestSuite<T>,
459
+ name: string,
460
+ options: Omit<ItDefinition<T>, "fn" | "name" | "suite">,
461
+ fn: (this: T, t: dntShim.Deno.TestContext) => void | Promise<void>,
462
+ ]
463
+ | [
464
+ suite: TestSuite<T>,
465
+ options: Omit<ItDefinition<T>, "fn" | "suite">,
466
+ fn: (this: T, t: dntShim.Deno.TestContext) => void | Promise<void>,
467
+ ]
468
+ | [
469
+ suite: TestSuite<T>,
470
+ options: Omit<ItDefinition<T>, "fn" | "name" | "suite">,
471
+ fn: (this: T, t: dntShim.Deno.TestContext) => void | Promise<void>,
472
+ ];
473
+
474
+ /** Generates an ItDefinition from ItArgs. */
475
+ function itDefinition<T>(...args: ItArgs<T>): ItDefinition<T> {
476
+ let [
477
+ suiteOptionsOrNameOrFn,
478
+ optionsOrNameOrFn,
479
+ optionsOrFn,
480
+ fn,
481
+ ] = args;
482
+ let suite: TestSuite<T> | undefined = undefined;
483
+ let name: string;
484
+ let options:
485
+ | ItDefinition<T>
486
+ | Omit<ItDefinition<T>, "fn">
487
+ | Omit<ItDefinition<T>, "name">
488
+ | Omit<ItDefinition<T>, "fn" | "name">;
489
+ if (
490
+ typeof suiteOptionsOrNameOrFn === "object" &&
491
+ typeof (suiteOptionsOrNameOrFn as TestSuite<T>).symbol === "symbol"
492
+ ) {
493
+ suite = suiteOptionsOrNameOrFn as TestSuite<T>;
494
+ } else {
495
+ fn = optionsOrFn as typeof fn;
496
+ optionsOrFn = optionsOrNameOrFn as typeof optionsOrFn;
497
+ optionsOrNameOrFn = suiteOptionsOrNameOrFn as typeof optionsOrNameOrFn;
498
+ }
499
+ if (typeof optionsOrNameOrFn === "string") {
500
+ name = optionsOrNameOrFn;
501
+ if (typeof optionsOrFn === "function") {
502
+ fn = optionsOrFn;
503
+ options = {};
504
+ } else {
505
+ options = optionsOrFn!;
506
+ if (!fn) fn = (options as Omit<ItDefinition<T>, "name">).fn;
507
+ }
508
+ } else if (typeof optionsOrNameOrFn === "function") {
509
+ fn = optionsOrNameOrFn;
510
+ name = fn.name;
511
+ options = {};
512
+ } else {
513
+ options = optionsOrNameOrFn!;
514
+ if (typeof optionsOrFn === "function") {
515
+ fn = optionsOrFn;
516
+ } else {
517
+ fn = (options as ItDefinition<T>).fn;
518
+ }
519
+ name = (options as ItDefinition<T>).name ?? fn.name;
520
+ }
521
+
522
+ return {
523
+ ...(suite !== undefined ? { suite } : {}),
524
+ ...options,
525
+ name,
526
+ fn,
527
+ };
528
+ }
529
+
530
+ /** Registers an individual test case. */
531
+ export interface it {
532
+ <T>(...args: ItArgs<T>): void;
533
+
534
+ /** Registers an individual test case with only set to true. */
535
+ only<T>(...args: ItArgs<T>): void;
536
+
537
+ /** Registers an individual test case with ignore set to true. */
538
+ ignore<T>(...args: ItArgs<T>): void;
539
+
540
+ /**
541
+ * Registers an individual test case with ignore set to true. Alias of
542
+ * `.ignore()`.
543
+ */
544
+ skip<T>(...args: ItArgs<T>): void;
545
+ }
546
+
547
+ /**
548
+ * Registers an individual test case.
549
+ *
550
+ * @example Usage
551
+ * ```ts
552
+ * import { describe, it } from "@std/testing/bdd";
553
+ * import { assertEquals } from "@std/assert";
554
+ *
555
+ * describe("example", () => {
556
+ * it("should pass", () => {
557
+ * // test case
558
+ * assertEquals(2 + 2, 4);
559
+ * });
560
+ * });
561
+ * ```
562
+ *
563
+ * @typeParam T The self type of the function to implement the test case
564
+ * @param args The test case
565
+ */
566
+ export function it<T>(...args: ItArgs<T>) {
567
+ if (TestSuiteInternal.runningCount > 0) {
568
+ throw new Error(
569
+ "Cannot register new test cases after already registered test cases start running",
570
+ );
571
+ }
572
+ const assertionState = getAssertionState();
573
+ const options = itDefinition(...args);
574
+ const { suite } = options;
575
+ const testSuite = suite
576
+ ? TestSuiteInternal.suites.get(suite.symbol)
577
+ : TestSuiteInternal.current;
578
+
579
+ if (!TestSuiteInternal.started) TestSuiteInternal.started = true;
580
+ if (testSuite) {
581
+ TestSuiteInternal.addStep(testSuite, options);
582
+ } else {
583
+ const {
584
+ name,
585
+ fn,
586
+ ignore,
587
+ only,
588
+ permissions,
589
+ sanitizeExit,
590
+ sanitizeOps,
591
+ sanitizeResources,
592
+ } = options;
593
+ const opts: dntShim.Deno.TestDefinition = {
594
+ name,
595
+ async fn(t) {
596
+ TestSuiteInternal.runningCount++;
597
+ try {
598
+ await fn.call({} as T, t);
599
+ } finally {
600
+ TestSuiteInternal.runningCount--;
601
+ }
602
+
603
+ if (assertionState.checkAssertionErrorState()) {
604
+ throw new AssertionError(
605
+ "Expected at least one assertion to be called but received none",
606
+ );
607
+ }
608
+
609
+ if (assertionState.checkAssertionCountSatisfied()) {
610
+ throw new AssertionError(
611
+ `Expected at least ${assertionState.assertionCount} assertion to be called, ` +
612
+ `but received ${assertionState.assertionTriggeredCount}`,
613
+ );
614
+ }
615
+
616
+ assertionState.resetAssertionState();
617
+ },
618
+ };
619
+ if (ignore !== undefined) {
620
+ opts.ignore = ignore;
621
+ }
622
+ if (only !== undefined) {
623
+ opts.only = only;
624
+ }
625
+ if (permissions !== undefined) {
626
+ opts.permissions = permissions;
627
+ }
628
+ if (sanitizeExit !== undefined) {
629
+ opts.sanitizeExit = sanitizeExit;
630
+ }
631
+ if (sanitizeOps !== undefined) {
632
+ opts.sanitizeOps = sanitizeOps;
633
+ }
634
+ if (sanitizeResources !== undefined) {
635
+ opts.sanitizeResources = sanitizeResources;
636
+ }
637
+ TestSuiteInternal.registerTest(opts);
638
+ }
639
+ }
640
+
641
+ /**
642
+ * Only execute this test case.
643
+ *
644
+ * @example Usage
645
+ * ```ts
646
+ * import { describe, it } from "@std/testing/bdd";
647
+ * import { assertEquals } from "@std/assert";
648
+ *
649
+ * describe("example", () => {
650
+ * it("should pass", () => {
651
+ * assertEquals(2 + 2, 4);
652
+ * });
653
+ *
654
+ * it.only("should pass too", () => {
655
+ * assertEquals(3 + 4, 7);
656
+ * });
657
+ * });
658
+ * ```
659
+ *
660
+ * @param args The test case
661
+ */
662
+ it.only = function itOnly<T>(...args: ItArgs<T>): void {
663
+ const options = itDefinition(...args);
664
+ return it({
665
+ ...options,
666
+ only: true,
667
+ });
668
+ };
669
+
670
+ /**
671
+ * Ignore this test case.
672
+ *
673
+ * @example Usage
674
+ * ```ts
675
+ * import { describe, it } from "@std/testing/bdd";
676
+ * import { assertEquals } from "@std/assert";
677
+ *
678
+ * describe("example", () => {
679
+ * it("should pass", () => {
680
+ * assertEquals(2 + 2, 4);
681
+ * });
682
+ *
683
+ * it.ignore("should pass too", () => {
684
+ * assertEquals(3 + 4, 7);
685
+ * });
686
+ * });
687
+ * ```
688
+ *
689
+ * @param args The test case
690
+ */
691
+ it.ignore = function itIgnore<T>(...args: ItArgs<T>): void {
692
+ const options = itDefinition(...args);
693
+ return it({
694
+ ...options,
695
+ ignore: true,
696
+ });
697
+ };
698
+
699
+ /** Skip this test case.
700
+ *
701
+ * @example Usage
702
+ * ```ts
703
+ * import { describe, it } from "@std/testing/bdd";
704
+ * import { assertEquals } from "@std/assert";
705
+ *
706
+ * describe("example", () => {
707
+ * it("should pass", () => {
708
+ * assertEquals(2 + 2, 4);
709
+ * });
710
+ *
711
+ * it.skip("should pass too", () => {
712
+ * assertEquals(3 + 4, 7);
713
+ * });
714
+ * });
715
+ * ```
716
+ *
717
+ * @param args The test case
718
+ */
719
+ it.skip = function itSkip<T>(...args: ItArgs<T>): void {
720
+ it.ignore(...args);
721
+ };
722
+
723
+ /**
724
+ * Alias of {@linkcode it}
725
+ *
726
+ * Registers an individual test case.
727
+ *
728
+ * @example Usage
729
+ * ```ts
730
+ * import { test } from "@std/testing/bdd";
731
+ * import { assertEquals } from "@std/assert";
732
+ *
733
+ * test("a test case", () => {
734
+ * // test case
735
+ * assertEquals(2 + 2, 4);
736
+ * });
737
+ * ```
738
+ *
739
+ * @typeParam T The self type of the function to implement the test case
740
+ * @param args The test case
741
+ */
742
+ export function test<T>(...args: ItArgs<T>) {
743
+ it(...args);
744
+ }
745
+
746
+ /**
747
+ * Only execute this test case.
748
+ *
749
+ * @example Usage
750
+ * ```ts
751
+ * import { describe, test } from "@std/testing/bdd";
752
+ * import { assertEquals } from "@std/assert";
753
+ *
754
+ * describe("example", () => {
755
+ * test("should pass", () => {
756
+ * assertEquals(2 + 2, 4);
757
+ * });
758
+ *
759
+ * test.only("should pass too", () => {
760
+ * assertEquals(3 + 4, 7);
761
+ * });
762
+ * });
763
+ * ```
764
+ *
765
+ * @param args The test case
766
+ */
767
+ test.only = function itOnly<T>(...args: ItArgs<T>): void {
768
+ it.only(...args);
769
+ };
770
+
771
+ /**
772
+ * Ignore this test case.
773
+ *
774
+ * @example Usage
775
+ * ```ts
776
+ * import { describe, test } from "@std/testing/bdd";
777
+ * import { assertEquals } from "@std/assert";
778
+ *
779
+ * describe("example", () => {
780
+ * test("should pass", () => {
781
+ * assertEquals(2 + 2, 4);
782
+ * });
783
+ *
784
+ * test.ignore("should pass too", () => {
785
+ * assertEquals(3 + 4, 7);
786
+ * });
787
+ * });
788
+ * ```
789
+ *
790
+ * @param args The test case
791
+ */
792
+ test.ignore = function itIgnore<T>(...args: ItArgs<T>): void {
793
+ it.ignore(...args);
794
+ };
795
+
796
+ /** Skip this test case.
797
+ *
798
+ * @example Usage
799
+ * ```ts
800
+ * import { describe, test } from "@std/testing/bdd";
801
+ * import { assertEquals } from "@std/assert";
802
+ *
803
+ * describe("example", () => {
804
+ * test("should pass", () => {
805
+ * assertEquals(2 + 2, 4);
806
+ * });
807
+ *
808
+ * test.skip("should pass too", () => {
809
+ * assertEquals(3 + 4, 7);
810
+ * });
811
+ * });
812
+ * ```
813
+ *
814
+ * @param args The test case
815
+ */
816
+ test.skip = function itSkip<T>(...args: ItArgs<T>): void {
817
+ it.ignore(...args);
818
+ };
819
+
820
+ function addHook<T>(
821
+ name: HookNames,
822
+ fn: (this: T) => void | Promise<void>,
823
+ ) {
824
+ if (!TestSuiteInternal.current) {
825
+ if (TestSuiteInternal.started) {
826
+ throw new Error(
827
+ "Cannot add global hooks after a global test is registered",
828
+ );
829
+ }
830
+ TestSuiteInternal.current = new TestSuiteInternal({
831
+ name: "global",
832
+ [name]: fn,
833
+ });
834
+ } else {
835
+ TestSuiteInternal.setHook(TestSuiteInternal.current!, name, fn);
836
+ }
837
+ }
838
+
839
+ /**
840
+ * Run some shared setup before all of the tests in the suite.
841
+ *
842
+ * @example Usage
843
+ * ```ts
844
+ * import { describe, it, beforeAll } from "@std/testing/bdd";
845
+ * import { assertEquals } from "@std/assert";
846
+ *
847
+ * beforeAll(() => {
848
+ * console.log("beforeAll");
849
+ * });
850
+ *
851
+ * describe("example", () => {
852
+ * it("should pass", () => {
853
+ * // test case
854
+ * assertEquals(2 + 2, 4);
855
+ * });
856
+ * });
857
+ * ```
858
+ *
859
+ * @typeParam T The self type of the function
860
+ * @param fn The function to implement the setup behavior.
861
+ */
862
+ export function beforeAll<T>(
863
+ fn: (this: T) => void | Promise<void>,
864
+ ) {
865
+ addHook("beforeAll", fn);
866
+ }
867
+
868
+ /**
869
+ * Alias of {@linkcode beforeAll}
870
+ *
871
+ * Run some shared setup before all of the tests in the suite.
872
+ *
873
+ * @example Usage
874
+ * ```ts
875
+ * import { describe, it, before } from "@std/testing/bdd";
876
+ * import { assertEquals } from "@std/assert";
877
+ *
878
+ * before(() => {
879
+ * console.log("before");
880
+ * });
881
+ *
882
+ * describe("example", () => {
883
+ * it("should pass", () => {
884
+ * // test case
885
+ * assertEquals(2 + 2, 4);
886
+ * });
887
+ * });
888
+ * ```
889
+ *
890
+ * @typeParam T The self type of the function
891
+ * @param fn The function to implement the setup behavior.
892
+ */
893
+ export function before<T>(
894
+ fn: (this: T) => void | Promise<void>,
895
+ ) {
896
+ beforeAll(fn);
897
+ }
898
+
899
+ /**
900
+ * Run some shared teardown after all of the tests in the suite.
901
+ *
902
+ * @example Usage
903
+ * ```ts
904
+ * import { describe, it, afterAll } from "@std/testing/bdd";
905
+ * import { assertEquals } from "@std/assert";
906
+ *
907
+ * afterAll(() => {
908
+ * console.log("afterAll");
909
+ * });
910
+ *
911
+ * describe("example", () => {
912
+ * it("should pass", () => {
913
+ * // test case
914
+ * assertEquals(2 + 2, 4);
915
+ * });
916
+ * });
917
+ * ```
918
+ *
919
+ * @typeParam T The self type of the function
920
+ * @param fn The function to implement the teardown behavior.
921
+ */
922
+ export function afterAll<T>(
923
+ fn: (this: T) => void | Promise<void>,
924
+ ) {
925
+ addHook("afterAll", fn);
926
+ }
927
+
928
+ /**
929
+ * Alias of {@linkcode afterAll}.
930
+ *
931
+ * Run some shared teardown after all of the tests in the suite.
932
+ *
933
+ * @example Usage
934
+ * ```ts
935
+ * import { describe, it, after } from "@std/testing/bdd";
936
+ * import { assertEquals } from "@std/assert";
937
+ *
938
+ * after(() => {
939
+ * console.log("after");
940
+ * });
941
+ *
942
+ * describe("example", () => {
943
+ * it("should pass", () => {
944
+ * // test case
945
+ * assertEquals(2 + 2, 4);
946
+ * });
947
+ * });
948
+ * ```
949
+ *
950
+ * @typeParam T The self type of the function
951
+ * @param fn The function to implement the teardown behavior.
952
+ */
953
+ export function after<T>(
954
+ fn: (this: T) => void | Promise<void>,
955
+ ) {
956
+ afterAll(fn);
957
+ }
958
+
959
+ /**
960
+ * Run some shared setup before each test in the suite.
961
+ *
962
+ * @example Usage
963
+ * ```ts
964
+ * import { describe, it, beforeEach } from "@std/testing/bdd";
965
+ * import { assertEquals } from "@std/assert";
966
+ *
967
+ * beforeEach(() => {
968
+ * console.log("beforeEach");
969
+ * });
970
+ *
971
+ * describe("example", () => {
972
+ * it("should pass", () => {
973
+ * // test case
974
+ * assertEquals(2 + 2, 4);
975
+ * });
976
+ * });
977
+ * ```
978
+ *
979
+ * @typeParam T The self type of the function
980
+ * @param fn The function to implement the shared setup behavior
981
+ */
982
+ export function beforeEach<T>(
983
+ fn: (this: T) => void | Promise<void>,
984
+ ) {
985
+ addHook("beforeEach", fn);
986
+ }
987
+
988
+ /**
989
+ * Run some shared teardown after each test in the suite.
990
+ *
991
+ * @example Usage
992
+ * ```ts
993
+ * import { describe, it, afterEach } from "@std/testing/bdd";
994
+ * import { assertEquals } from "@std/assert";
995
+ *
996
+ * afterEach(() => {
997
+ * console.log("afterEach");
998
+ * });
999
+ *
1000
+ * describe("example", () => {
1001
+ * it("should pass", () => {
1002
+ * // test case
1003
+ * assertEquals(2 + 2, 4);
1004
+ * });
1005
+ * });
1006
+ * ```
1007
+ *
1008
+ * @typeParam T The self type of the function
1009
+ * @param fn The function to implement the shared teardown behavior
1010
+ */
1011
+ export function afterEach<T>(
1012
+ fn: (this: T) => void | Promise<void>,
1013
+ ) {
1014
+ addHook("afterEach", fn);
1015
+ }
1016
+
1017
+ /** The arguments for a DescribeFunction. */
1018
+ export type DescribeArgs<T> =
1019
+ | [options: DescribeDefinition<T>]
1020
+ | [name: string]
1021
+ | [
1022
+ name: string,
1023
+ options: Omit<DescribeDefinition<T>, "name">,
1024
+ ]
1025
+ | [name: string, fn: () => void | undefined]
1026
+ | [fn: () => void | undefined]
1027
+ | [
1028
+ name: string,
1029
+ options: Omit<DescribeDefinition<T>, "fn" | "name">,
1030
+ fn: () => void | undefined,
1031
+ ]
1032
+ | [
1033
+ options: Omit<DescribeDefinition<T>, "fn">,
1034
+ fn: () => void | undefined,
1035
+ ]
1036
+ | [
1037
+ options: Omit<DescribeDefinition<T>, "fn" | "name">,
1038
+ fn: () => void | undefined,
1039
+ ]
1040
+ | [
1041
+ suite: TestSuite<T>,
1042
+ name: string,
1043
+ ]
1044
+ | [
1045
+ suite: TestSuite<T>,
1046
+ name: string,
1047
+ options: Omit<DescribeDefinition<T>, "name" | "suite">,
1048
+ ]
1049
+ | [
1050
+ suite: TestSuite<T>,
1051
+ name: string,
1052
+ fn: () => void | undefined,
1053
+ ]
1054
+ | [
1055
+ suite: TestSuite<T>,
1056
+ fn: () => void | undefined,
1057
+ ]
1058
+ | [
1059
+ suite: TestSuite<T>,
1060
+ name: string,
1061
+ options: Omit<DescribeDefinition<T>, "fn" | "name" | "suite">,
1062
+ fn: () => void | undefined,
1063
+ ]
1064
+ | [
1065
+ suite: TestSuite<T>,
1066
+ options: Omit<DescribeDefinition<T>, "fn" | "suite">,
1067
+ fn: () => void | undefined,
1068
+ ]
1069
+ | [
1070
+ suite: TestSuite<T>,
1071
+ options: Omit<DescribeDefinition<T>, "fn" | "name" | "suite">,
1072
+ fn: () => void | undefined,
1073
+ ];
1074
+
1075
+ /** Generates a DescribeDefinition from DescribeArgs. */
1076
+ function describeDefinition<T>(
1077
+ ...args: DescribeArgs<T>
1078
+ ): DescribeDefinition<T> {
1079
+ let [
1080
+ suiteOptionsOrNameOrFn,
1081
+ optionsOrNameOrFn,
1082
+ optionsOrFn,
1083
+ fn,
1084
+ ] = args;
1085
+ let suite: TestSuite<T> | undefined = undefined;
1086
+ let name: string;
1087
+ let options:
1088
+ | DescribeDefinition<T>
1089
+ | Omit<DescribeDefinition<T>, "fn">
1090
+ | Omit<DescribeDefinition<T>, "name">
1091
+ | Omit<DescribeDefinition<T>, "fn" | "name">;
1092
+ if (
1093
+ typeof suiteOptionsOrNameOrFn === "object" &&
1094
+ typeof (suiteOptionsOrNameOrFn as TestSuite<T>).symbol === "symbol"
1095
+ ) {
1096
+ suite = suiteOptionsOrNameOrFn as TestSuite<T>;
1097
+ } else {
1098
+ fn = optionsOrFn as typeof fn;
1099
+ optionsOrFn = optionsOrNameOrFn as typeof optionsOrFn;
1100
+ optionsOrNameOrFn = suiteOptionsOrNameOrFn as typeof optionsOrNameOrFn;
1101
+ }
1102
+ if (typeof optionsOrNameOrFn === "string") {
1103
+ name = optionsOrNameOrFn;
1104
+ if (typeof optionsOrFn === "function") {
1105
+ fn = optionsOrFn;
1106
+ options = {};
1107
+ } else {
1108
+ options = optionsOrFn ?? {};
1109
+ if (fn === undefined) {
1110
+ fn = (options as Omit<DescribeDefinition<T>, "name">).fn;
1111
+ }
1112
+ }
1113
+ } else if (typeof optionsOrNameOrFn === "function") {
1114
+ fn = optionsOrNameOrFn;
1115
+ name = fn.name;
1116
+ options = {};
1117
+ } else {
1118
+ options = optionsOrNameOrFn ?? {};
1119
+ if (typeof optionsOrFn === "function") {
1120
+ fn = optionsOrFn;
1121
+ } else {
1122
+ fn = (options as DescribeDefinition<T>).fn;
1123
+ }
1124
+ name = (options as DescribeDefinition<T>).name ?? fn?.name ?? "";
1125
+ }
1126
+
1127
+ if (suite === undefined) {
1128
+ suite = options.suite;
1129
+ }
1130
+ if (suite === undefined && TestSuiteInternal.current) {
1131
+ const { symbol } = TestSuiteInternal.current;
1132
+ suite = { symbol };
1133
+ }
1134
+
1135
+ return {
1136
+ ...options,
1137
+ suite: suite!,
1138
+ name,
1139
+ fn: fn!,
1140
+ };
1141
+ }
1142
+
1143
+ /** Registers a test suite. */
1144
+ export interface describe {
1145
+ <T>(...args: DescribeArgs<T>): TestSuite<T>;
1146
+
1147
+ /** Registers a test suite with only set to true. */
1148
+ only<T>(...args: DescribeArgs<T>): TestSuite<T>;
1149
+
1150
+ /** Registers a test suite with ignore set to true. */
1151
+ ignore<T>(...args: DescribeArgs<T>): TestSuite<T>;
1152
+
1153
+ /** Registers a test suite with ignore set to true. Alias of `.ignore()`. */
1154
+ skip<T>(...args: ItArgs<T>): void;
1155
+ }
1156
+
1157
+ /**
1158
+ * Registers a test suite.
1159
+ *
1160
+ * @example Usage
1161
+ * ```ts
1162
+ * import { describe, it } from "@std/testing/bdd";
1163
+ * import { assertEquals } from "@std/assert";
1164
+ *
1165
+ * describe("example", () => {
1166
+ * it("should pass", () => {
1167
+ * // test case
1168
+ * assertEquals(2 + 2, 4);
1169
+ * });
1170
+ * });
1171
+ * ```
1172
+ *
1173
+ * @typeParam T The self type of the test suite body.
1174
+ * @param args The test suite body.
1175
+ * @returns The test suite
1176
+ */
1177
+ export function describe<T>(
1178
+ ...args: DescribeArgs<T>
1179
+ ): TestSuite<T> {
1180
+ if (TestSuiteInternal.runningCount > 0) {
1181
+ throw new Error(
1182
+ "Cannot register new test suites after already registered test cases start running",
1183
+ );
1184
+ }
1185
+ const options = describeDefinition(...args);
1186
+ if (!TestSuiteInternal.started) TestSuiteInternal.started = true;
1187
+ const { symbol } = new TestSuiteInternal(options);
1188
+ return { symbol };
1189
+ }
1190
+
1191
+ /**
1192
+ * Only execute this test suite.
1193
+ *
1194
+ * @example Usage
1195
+ * ```ts
1196
+ * import { describe, it, beforeAll } from "@std/testing/bdd";
1197
+ * import { assertEquals } from "@std/assert";
1198
+ *
1199
+ * describe("example", () => {
1200
+ * it("should pass", () => {
1201
+ * assertEquals(2 + 2, 4);
1202
+ * });
1203
+ * });
1204
+ *
1205
+ * // Only this test suite will run
1206
+ * describe.only("example 2", () => {
1207
+ * it("should pass too", () => {
1208
+ * assertEquals(3 + 4, 7);
1209
+ * });
1210
+ * });
1211
+ * ```
1212
+ *
1213
+ * @param args The test suite body
1214
+ */
1215
+ describe.only = function describeOnly<T>(
1216
+ ...args: DescribeArgs<T>
1217
+ ): TestSuite<T> {
1218
+ const options = describeDefinition(...args);
1219
+ return describe({
1220
+ ...options,
1221
+ only: true,
1222
+ });
1223
+ };
1224
+
1225
+ /**
1226
+ * Ignore the test suite.
1227
+ *
1228
+ * @example Usage
1229
+ * ```ts
1230
+ * import { describe, it, beforeAll } from "@std/testing/bdd";
1231
+ * import { assertEquals } from "@std/assert";
1232
+ *
1233
+ * describe("example", () => {
1234
+ * it("should pass", () => {
1235
+ * assertEquals(2 + 2, 4);
1236
+ * });
1237
+ * });
1238
+ *
1239
+ * describe.ignore("example 2", () => {
1240
+ * it("should pass too", () => {
1241
+ * assertEquals(3 + 4, 7);
1242
+ * });
1243
+ * });
1244
+ * ```
1245
+ *
1246
+ * @param args The test suite body
1247
+ */
1248
+ describe.ignore = function describeIgnore<T>(
1249
+ ...args: DescribeArgs<T>
1250
+ ): TestSuite<T> {
1251
+ const options = describeDefinition(...args);
1252
+ return describe({
1253
+ ...options,
1254
+ ignore: true,
1255
+ });
1256
+ };
1257
+
1258
+ /**
1259
+ * Skip the test suite.
1260
+ *
1261
+ * @example Usage
1262
+ * ```ts
1263
+ * import { describe, it, beforeAll } from "@std/testing/bdd";
1264
+ * import { assertEquals } from "@std/assert";
1265
+ *
1266
+ * describe("example", () => {
1267
+ * it("should pass", () => {
1268
+ * assertEquals(2 + 2, 4);
1269
+ * });
1270
+ * });
1271
+ *
1272
+ * describe.skip("example 2", () => {
1273
+ * it("should pass too", () => {
1274
+ * assertEquals(3 + 4, 7);
1275
+ * });
1276
+ * });
1277
+ * ```
1278
+ *
1279
+ * @param args The test suite body
1280
+ */
1281
+ describe.skip = function describeSkip<T>(
1282
+ ...args: DescribeArgs<T>
1283
+ ): TestSuite<T> {
1284
+ return describe.ignore(...args);
1285
+ };