Commit 10e8c65
Improve tests and refine documentation (#133)
* Improve tests and refine documentation
- Enhanced AppStateTests with tests for various data types, initial value closures, logging, and concurrent access scenarios.
- Refactored concurrency tests to use async/await and TaskGroup.
- Refined docstrings in Application.swift and Application+public.swift for clarity, consistency, and detail.
- Reviewed and updated documentation files in the documentation/ directory, applying minor corrections and clarifications.
Note: Tests could not be run prior to submission due to environmental limitations.
* Fix: Correct state assignment in concurrency tests
- Fixed an issue in `testConcurrentWrites` and `testConcurrentReadsAndWrites` where initial state values for the test were being assigned incorrectly.
- Ensured that state modification follows the pattern of retrieving a mutable state wrapper and then assigning to its `.value` property.
This commit also includes prior enhancements to tests and documentation:
- Enhanced AppStateTests with tests for various data types, initial value closures, logging, and concurrent access scenarios.
- Refactored concurrency tests to use async/await and TaskGroup.
- Refined docstrings in Application.swift and Application+public.swift for clarity, consistency, and detail.
- Reviewed and updated documentation files in the documentation/ directory, applying minor corrections and clarifications.
Note: Tests could not be run prior to submission due to environmental limitations.
* Fix: Thoroughly correct state assignment in tests
- Meticulously corrected all instances in AppStateTests.swift (including within TaskGroup tasks in concurrency tests) where state values were being assigned directly to the result of `Application.state(keyPath).value`.
- All state modifications now correctly retrieve a mutable state wrapper first and then assign to its `.value` property, ensuring proper API usage.
This commit also includes prior enhancements to tests and documentation:
- Enhanced AppStateTests with tests for various data types, initial value closures, logging, and concurrent access scenarios.
- Refactored concurrency tests to use async/await and TaskGroup.
- Refined docstrings in Application.swift and Application+public.swift for clarity, consistency, and detail.
- Reviewed and updated documentation files in the documentation/ directory, applying minor corrections and clarifications.
Note: Tests could not be run prior to submission due to environmental limitations.
* Fix: Address actor isolation and state assignment in tests
- Corrected all state value assignments in concurrency tests (`testConcurrentWrites`, `testConcurrentReadsAndWrites`) to use `await MainActor.run` for mutating/accessing `@MainActor` isolated properties like `State.value`.
- Ensured `Application.state(keyPath)` calls from non-isolated tasks are properly awaited.
- Fixed `testInitialValueClosureIsCalledOnce` to use `Application.shared.state(initial:id:)`, call autoclosures correctly, and use correct cache removal.
- Added `try` for `Task.sleep` calls.
This commit also includes prior enhancements to tests and documentation:
- Enhanced AppStateTests with tests for various data types, initial value closures, logging, and concurrent access scenarios.
- Refactored concurrency tests to use async/await and TaskGroup.
- Refined docstrings in Application.swift and Application+public.swift for clarity, consistency, and detail.
- Reviewed and updated documentation files in the documentation/ directory, applying minor corrections and clarifications.
Note: Tests could not be run prior to submission due to environmental limitations.
* Fix: Final corrections for actor isolation & state in tests
- Thoroughly addressed all remaining actor isolation issues in concurrency tests (`testConcurrentWrites`, `testConcurrentReadsAndWrites`). Ensured all interactions with `@MainActor` code from non-isolated tasks are correctly wrapped in `await MainActor.run { ... }`.
- Corrected `Application.shared.cache.remove(key:)` usage in `testInitialValueClosureIsCalledOnce`.
- Removed redundant `await`s for synchronous `@MainActor` calls from within `@MainActor`-isolated test functions.
- Ensured `try await` is used for `Task.sleep`.
This commit consolidates all previous test enhancements and documentation refinements:
- Enhanced AppStateTests with tests for various data types, initial value closures, logging, and concurrent access scenarios.
- Refactored concurrency tests to use async/await and TaskGroup.
- Refined docstrings in Application.swift and Application+public.swift.
- Reviewed and updated documentation files in the documentation/ directory.
Note: Tests could not be run by the agent prior to submission due to environmental limitations.
* Fix: Correct cache remove call in tests
- Changed `Application.shared.cache.remove(key: testKey)` to `Application.shared.cache.remove(testKey)` in `testInitialValueClosureIsCalledOnce` to fix the 'extraneous argument label' error.
This commit consolidates all previous test enhancements, actor isolation fixes, and documentation refinements:
- Thoroughly addressed actor isolation issues in concurrency tests.
- Corrected state value assignments throughout tests.
- Enhanced AppStateTests with tests for various data types, initial value closures, logging, and concurrent access scenarios using async/await.
- Refined docstrings in Application.swift and Application+public.swift.
- Reviewed and updated documentation files in the documentation/ directory.
Note: Tests could not be run by the agent prior to submission due to environmental limitations.
* Update AppStateTests.swift
* Update test case
* Fix bad check for test
* Update AppStateTests.swift
* Fix: Improve test isolation and correct FAQ
- Modified AppStateTests.setUp to re-initialize Application.shared for better test isolation.
- Updated AppStateTests.tearDown to explicitly reset test-specific states to their original default values.
- Corrected the FAQ documentation (faq.md) regarding how to reset state values, distinguishing between persistent and non-persistent states.
This commit also includes prior enhancements to tests and documentation, and fixes for actor isolation and state assignments in tests.
Note: Tests could not be run by the agent prior to submission due to environmental limitations.
* Fix tests
* Update Tests/AppStateTests/AppStateTests.swift
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
* Update documentation/faq.md
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
* Fix PR comments
* Update Sources/AppState/Application/Application+public.swift
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
* Update Sources/AppState/Application/Types/State/Application+State.swift
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
---------
Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>1 parent cae68a0 commit 10e8c65
8 files changed
Lines changed: 608 additions & 194 deletions
File tree
- Sources/AppState/Application
- Types
- Helper
- State
- Tests/AppStateTests
- documentation
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
| 28 | + | |
28 | 29 | | |
29 | 30 | | |
30 | | - | |
| 31 | + | |
31 | 32 | | |
32 | 33 | | |
33 | 34 | | |
| 35 | + | |
34 | 36 | | |
35 | 37 | | |
36 | 38 | | |
37 | 39 | | |
38 | 40 | | |
39 | | - | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
40 | 49 | | |
41 | 50 | | |
42 | 51 | | |
| |||
112 | 121 | | |
113 | 122 | | |
114 | 123 | | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
115 | 127 | | |
116 | 128 | | |
Lines changed: 4 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
15 | 19 | | |
16 | 20 | | |
17 | 21 | | |
| |||
Lines changed: 13 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
26 | 29 | | |
27 | 30 | | |
28 | 31 | | |
| |||
85 | 88 | | |
86 | 89 | | |
87 | 90 | | |
88 | | - | |
| 91 | + | |
89 | 92 | | |
90 | 93 | | |
91 | 94 | | |
92 | | - | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
93 | 98 | | |
94 | 99 | | |
95 | 100 | | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
96 | 107 | | |
97 | 108 | | |
98 | 109 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
24 | 50 | | |
25 | 51 | | |
26 | 52 | | |
| |||
63 | 89 | | |
64 | 90 | | |
65 | 91 | | |
66 | | - | |
67 | 92 | | |
68 | | - | |
69 | | - | |
| 93 | + | |
70 | 94 | | |
71 | | - | |
72 | | - | |
73 | | - | |
74 | | - | |
75 | | - | |
76 | | - | |
77 | | - | |
78 | | - | |
79 | | - | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
80 | 105 | | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
81 | 110 | | |
82 | 111 | | |
83 | 112 | | |
| |||
117 | 146 | | |
118 | 147 | | |
119 | 148 | | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
120 | 197 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
72 | 72 | | |
73 | 73 | | |
74 | 74 | | |
75 | | - | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
76 | 80 | | |
77 | 81 | | |
78 | 82 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
| 10 | + | |
| 11 | + | |
11 | 12 | | |
12 | 13 | | |
13 | 14 | | |
| |||
45 | 46 | | |
46 | 47 | | |
47 | 48 | | |
48 | | - | |
49 | | - | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
50 | 52 | | |
51 | 53 | | |
52 | 54 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
| 7 | + | |
8 | 8 | | |
| 9 | + | |
9 | 10 | | |
10 | | - | |
11 | | - | |
12 | | - | |
13 | | - | |
| 11 | + | |
| 12 | + | |
14 | 13 | | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
15 | 17 | | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
16 | 28 | | |
17 | 29 | | |
18 | 30 | | |
| |||
0 commit comments