cfprotected 1.1.0 → 1.1.1
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/.vscode/launch.json +9 -5
- package/index.mjs +9 -0
- package/package.json +1 -1
- package/test/test.mjs +34 -9
package/.vscode/launch.json
CHANGED
|
@@ -4,16 +4,20 @@
|
|
|
4
4
|
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
|
|
5
5
|
"version": "0.2.0",
|
|
6
6
|
"configurations": [
|
|
7
|
+
|
|
7
8
|
{
|
|
8
9
|
"type": "node",
|
|
9
10
|
"request": "launch",
|
|
10
11
|
"name": "Jest Tests",
|
|
11
|
-
"
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
"${workspaceRoot}/
|
|
12
|
+
"runtimeArgs": [
|
|
13
|
+
"--experimental-vm-modules",
|
|
14
|
+
"--inspect-brk",
|
|
15
|
+
"${workspaceRoot}/node_modules/jest/bin/jest.js",
|
|
16
|
+
"--runInBand"
|
|
15
17
|
],
|
|
16
|
-
"
|
|
18
|
+
"internalConsoleOptions": "neverOpen",
|
|
19
|
+
"console": "integratedTerminal",
|
|
20
|
+
"port": 9229
|
|
17
21
|
}
|
|
18
22
|
]
|
|
19
23
|
}
|
package/index.mjs
CHANGED
|
@@ -167,6 +167,11 @@ function abstract(klass) {
|
|
|
167
167
|
super(...args);
|
|
168
168
|
}
|
|
169
169
|
};
|
|
170
|
+
|
|
171
|
+
if (memos.has(klass)) {
|
|
172
|
+
memos.set(retval, memos.get(klass));
|
|
173
|
+
}
|
|
174
|
+
|
|
170
175
|
return retval;
|
|
171
176
|
};
|
|
172
177
|
|
|
@@ -218,6 +223,10 @@ function final(klass) {
|
|
|
218
223
|
}
|
|
219
224
|
});
|
|
220
225
|
|
|
226
|
+
if (memos.has(klass)) {
|
|
227
|
+
memos.set(retval, memos.get(klass));
|
|
228
|
+
}
|
|
229
|
+
|
|
221
230
|
return retval;
|
|
222
231
|
};
|
|
223
232
|
|
package/package.json
CHANGED
package/test/test.mjs
CHANGED
|
@@ -138,31 +138,56 @@ describe(`Testing that $uper works in all cases`, () => {
|
|
|
138
138
|
});
|
|
139
139
|
|
|
140
140
|
describe(`Testing that abstract classes function as expected`, () => {
|
|
141
|
-
const
|
|
142
|
-
|
|
141
|
+
const key = Symbol();
|
|
142
|
+
const ATest = abstract(class ATest {
|
|
143
|
+
#shared = share(this, ATest, {
|
|
144
|
+
[key]: true
|
|
145
|
+
});
|
|
146
|
+
});
|
|
147
|
+
class DTest extends ATest {
|
|
148
|
+
#shared = share(this, DTest, {});
|
|
149
|
+
run() { return this.#shared[key]; }
|
|
150
|
+
};
|
|
143
151
|
|
|
144
|
-
test(`Should not be able to instantiate
|
|
152
|
+
test(`Should not be able to instantiate directly`, () => {
|
|
145
153
|
expect(() => { new ATest; }).toThrow();
|
|
146
154
|
});
|
|
147
|
-
test(`Should be able to instantiate a
|
|
155
|
+
test(`Should be able to instantiate a derived class`, () => {
|
|
148
156
|
expect(() => { new DTest; }).not.toThrow();
|
|
149
157
|
});
|
|
158
|
+
test(`Should see shared members from constructed instance`, () => {
|
|
159
|
+
expect((new DTest).run()).toBe(true);
|
|
160
|
+
});
|
|
150
161
|
});
|
|
151
162
|
|
|
152
163
|
describe(`Testing that final classes function as expected`, () => {
|
|
153
|
-
const
|
|
164
|
+
const key = Symbol();
|
|
165
|
+
class TestBase {
|
|
166
|
+
#shared = share(this, TestBase, {
|
|
167
|
+
[key]: true
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
const FTest = final(class FTest extends TestBase {
|
|
171
|
+
#shared = share(this, FTest, {});
|
|
172
|
+
run() {
|
|
173
|
+
return this.#shared[key];
|
|
174
|
+
}
|
|
175
|
+
});
|
|
154
176
|
|
|
155
|
-
test(`Should be able to instantiate an instance
|
|
177
|
+
test(`Should be able to instantiate an instance directly`, () => {
|
|
156
178
|
expect(() => { new FTest; }).not.toThrow();
|
|
157
179
|
});
|
|
158
|
-
test(`Should not be able to extend
|
|
180
|
+
test(`Should not be able to extend directly`, () => {
|
|
159
181
|
expect(() => { class DTest extends FTest {}; }).toThrow();
|
|
160
182
|
});
|
|
161
|
-
test(`Should not be able to cheat and create an instance of a
|
|
183
|
+
test(`Should not be able to cheat and create an instance of a derived class`, () => {
|
|
162
184
|
expect(() => {
|
|
163
185
|
FTest.prototype = {};
|
|
164
186
|
class DTest extends FTest {}
|
|
165
187
|
new DTest;
|
|
166
188
|
}).toThrow();
|
|
167
|
-
})
|
|
189
|
+
});
|
|
190
|
+
test(`Should see shared members from constructed instance`, () => {
|
|
191
|
+
expect((new FTest).run()).toBe(true);
|
|
192
|
+
});
|
|
168
193
|
});
|