Repository navigation
Expand file tree
/
Copy pathtest.js
More file actions
93 lines (75 loc) · 2.18 KB
/
Copy pathtest.js
File metadata and controls
93 lines (75 loc) · 2.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
const assert = require('assert')
const Capsulable = require('../..')
const A = require('./a')
const B = require('./b')
const Expanded = require('./expanded')
const C = require('./c')
const UnitTest = require('./unit')
module.exports = ()=>{
/**
* @description
* Test single-class
*/
let sharedA = Capsulable(A)
let a1 = new sharedA()
let a2 = new sharedA()
// Private Test
// Protected Test
// Protected Static Test
UnitTest(a1, a2)
/**
* @description
* Test after inherit class
* (Expanding and inheriting classes after encapsulation)
*/
let expanded = Expanded(sharedA)
let expandedA = new expanded()
// Individual value Protected Abstraction Test by Child Class
assert(expandedA.getProtected() == undefined)
expandedA.setProtected(26)
assert(a1.getProtected() == 24)
assert(a2.getProtected() == 25)
assert(expandedA.getProtected() == 26)
let expandedAgain = Expanded(expanded)
let expandedAgainA = new expandedAgain()
assert(expandedAgainA.getProtected() == undefined)
expandedAgainA.setProtected(27)
assert(a1.getProtected() == 24)
assert(a2.getProtected() == 25)
assert(expandedA.getProtected() == 26)
assert(expandedAgainA.getProtected() == 27)
/**
* @description
* Test multiple-class package
*/
let packages = Capsulable([A, B])
let packA = new packages.A()
let packB = new packages.B()
// Private Test
// Protected Test
// Protected Static Test
UnitTest(packA, packB)
/**
* @description
* Tests to add classes after package configuration.
*/
packages._load(C)
// Protected Static Test
let packC = new packages.C()
// Private Test
// Protected Test
// Protected Static Test
UnitTest(packB, packC)
// Final mode Test
let FinalClass = Capsulable(A, 'final')
class FailureClass extends FinalClass{
constructor(inherit){
let hook = {}
super(hook)
assert(typeof hook['field'] === 'undefined')
// Field(this, hook.field)
// if(inherit) Capsulable(hook, inherit)
}
}
new FailureClass()
}