risei 3.2.0 → 3.3.0

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.
package/README.md CHANGED
@@ -46,7 +46,7 @@ And they have a summary bar at the bottom:
46
46
 
47
47
  ## Status
48
48
 
49
- Risei's major features are now complete, but new enhancements or fixes may appear from time to time.  The latest release, **3.2.0**, includes significant improvements and bug fixes, on top of the major improvements in releases **3.0.0** and **2.0.0**.
49
+ Risei's major features are now complete, but new enhancements or fixes may appear from time to time.  The latest release, **3.3.0**, brings further significant improvements and bug fixes on top of the major improvements in other recent releases.
50
50
 
51
51
  Check out the [full list of changes](#version-history).
52
52
 
@@ -219,6 +219,14 @@ If errors are thrown while testing, gold bars listing them appear at the bottom,
219
219
 
220
220
  ## Version history
221
221
 
222
+ - Release **3.3.0** (January, 2025) adds this change to those of other recent releases:
223
+ - You can now test instance members with the same names as static members using a new `.and` option of `"instance"`.
224
+
225
+
226
+ - Release **3.2.1** (January, 2025) contains all the changes from **3.2.0**, **3.1.1**, and **3.1.0**, plus this change:
227
+ - Risei's mistaken nominal dependency on **npm** has been removed.
228
+
229
+
222
230
  - Release **3.2.0** (January, 2025) contains all the changes from **3.1.1** and **3.1.0**, plus this change:
223
231
  - Risei's self-dependency for its own self-testing has been moved back to the development-only scope.
224
232
 
@@ -274,7 +282,7 @@ Older releases
274
282
 
275
283
  ## Known issues and workarounds
276
284
 
277
- There are two minor issues at present:
285
+ There are two minor issues:
278
286
 
279
287
  - If args for a test are mutated by tested code, the mutated args are used when collapsing forward.
280
288
  - The workaround is just to restate those args for each test.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "risei",
3
- "version": "3.2.0",
3
+ "version": "3.3.0",
4
4
  "description": "Risei allows you to write unit tests as simple JavaScript objects, so it's easy and fast, with no drag on redesign.",
5
5
  "keywords": [
6
6
  "unit test",
@@ -41,8 +41,7 @@
41
41
  "dependencies": {
42
42
  "chalk": "^5.0.0",
43
43
  "fs": "^0.0.1-security",
44
- "minimatch": "^9.0.1",
45
- "npm": "^11.0.0"
44
+ "minimatch": "^9.0.1"
46
45
  },
47
46
  "devDependencies": {
48
47
  "chai": "^4.3.6",
@@ -51,6 +50,6 @@
51
50
  "fs": "^0.0.1-security",
52
51
  "mocha": "^10.0.0",
53
52
  "morgan": "~1.9.1",
54
- "risei": "^3.1.1"
53
+ "risei": "^3.2.1"
55
54
  }
56
55
  }
package/system/TestDef.js CHANGED
@@ -14,6 +14,7 @@ export default class TestDef {
14
14
  // region Definitions
15
15
 
16
16
  static staticName = "static";
17
+ static instanceName = "instance";
17
18
  static throwName = "throw";
18
19
  static polyName = "poly";
19
20
  static constructorName = "constructor";
@@ -173,16 +174,19 @@ export default class TestDef {
173
174
  }
174
175
 
175
176
  get isInstanceTest() /* passed */ {
176
- return !this.isStaticTest || this.isConstructorTest;
177
+ return this.#isNamedTypeTest(
178
+ TestDef.instanceName,
179
+ TestDef.staticName,
180
+ TypeAnalyzer.isInstanceMember
181
+ );
177
182
  }
178
183
 
179
184
  get isStaticTest() /* passed */ {
180
- let plainName = NameAnalyzer.plainNameOf(this.of);
181
-
182
- let is = TypeAnalyzer.isStaticMember(this.on, plainName);
183
- let stated = this.andStringContains(TestDef.staticName);
184
-
185
- return is || stated;
185
+ return this.#isNamedTypeTest(
186
+ TestDef.staticName,
187
+ TestDef.instanceName,
188
+ TypeAnalyzer.isStaticMember
189
+ );
186
190
  }
187
191
 
188
192
  get isThrowTest() /* passed */ {
@@ -308,6 +312,25 @@ export default class TestDef {
308
312
 
309
313
  // region State methods
310
314
 
315
+ /* Dependency of .isInstanceTest and .isStaticTest. */
316
+ #isNamedTypeTest(type, antiType, analyzer) /* verified */ {
317
+ // If stated to be the opposite type, not this type.
318
+ if (this.andStringContains(antiType)) {
319
+ return false;
320
+ }
321
+
322
+ // Analysis of what the type probably is.
323
+ let plainName = NameAnalyzer.plainNameOf(this.of);
324
+ let is = analyzer(this.on, plainName);
325
+
326
+ // If states to be this type, then this type.
327
+ let stated = this.andStringContains(type);
328
+
329
+ // Whichever may apply.
330
+ return is || stated;
331
+ }
332
+
333
+
311
334
  /* Needed externally, and dependency
312
335
  of all .and-based properties. */
313
336
  andStringContains(keyword) /* passed */ {
@@ -42,7 +42,7 @@ export default class TestStages {
42
42
  return;
43
43
  }
44
44
 
45
- let target = test.isInstanceTest
45
+ let target = test.isInstanceTest // || test.of === "toString"
46
46
  ? new test.on.prototype.constructor(...test.with)
47
47
  : test.on;
48
48