xdbc 1.0.95 → 1.0.97
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/settings.json +1 -1
- package/README.md +10 -3
- package/dist/DBC/COMPARISON/GREATER.js +6 -7
- package/dist/DBC/COMPARISON/GREATER_OR_EQUAL.js +21 -0
- package/dist/DBC/COMPARISON/LESS.js +21 -0
- package/dist/DBC/COMPARISON/LESS_OR_EQUAL.js +21 -0
- package/dist/DBC/COMPARISON.js +18 -18
- package/dist/Demo.js +24 -1
- package/dist/bundle.js +511 -25
- package/package.json +8 -3
- package/src/DBC/COMPARISON.ts +2 -2
- package/src/DBC/EQ/DIFFERENT.ts +35 -0
- package/src/DBC/HasAttribute.ts +140 -0
- package/src/DBC/IF.ts +147 -0
- package/src/DBC.ts +44 -1
- package/src/Demo.ts +163 -20
- package/webpack.config.js +1 -0
- package/src/DBC/GREATER.ts +0 -150
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.0.
|
|
2
|
+
"version": "1.0.97",
|
|
3
3
|
"name": "xdbc",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"docs": "typedoc",
|
|
@@ -25,7 +25,8 @@
|
|
|
25
25
|
"typescript": "^5.8.3",
|
|
26
26
|
"undici-types": "^7.8.0",
|
|
27
27
|
"webpack": "^5.99.8",
|
|
28
|
-
"webpack-cli": "^6.0.1"
|
|
28
|
+
"webpack-cli": "^6.0.1",
|
|
29
|
+
"webpack-dev-server": "^5.2.1"
|
|
29
30
|
},
|
|
30
31
|
"dependencies": {
|
|
31
32
|
"@types/reflect-metadata": "^0.1.0",
|
|
@@ -37,7 +38,11 @@
|
|
|
37
38
|
"type": "git",
|
|
38
39
|
"url": "git+https://github.com/CallariS/XDBC.git"
|
|
39
40
|
},
|
|
40
|
-
"keywords": [
|
|
41
|
+
"keywords": [
|
|
42
|
+
"DbC",
|
|
43
|
+
"DesignByContract",
|
|
44
|
+
"Typescript"
|
|
45
|
+
],
|
|
41
46
|
"author": "Callari, Salvatore",
|
|
42
47
|
"license": "MIT",
|
|
43
48
|
"bugs": {
|
package/src/DBC/COMPARISON.ts
CHANGED
|
@@ -20,7 +20,7 @@ export class COMPARISON extends DBC {
|
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
if (equalityPermitted && invert && toCheck > equivalent) {
|
|
23
|
-
return `Value
|
|
23
|
+
return `Value has to be less than or equal to "${equivalent}"`;
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
if (!equalityPermitted && !invert && toCheck <= equivalent) {
|
|
@@ -28,7 +28,7 @@ export class COMPARISON extends DBC {
|
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
if (!equalityPermitted && invert && toCheck >= equivalent) {
|
|
31
|
-
return `Value
|
|
31
|
+
return `Value has to be less than "${equivalent}"`;
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
return true;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { EQ } from "../EQ";
|
|
2
|
+
/** See {@link COMPARISON }. */
|
|
3
|
+
export class DIFFERENT extends EQ {
|
|
4
|
+
/** See {@link COMPARISON.PRE }. */
|
|
5
|
+
public static override PRE(
|
|
6
|
+
equivalent,
|
|
7
|
+
invert = false,
|
|
8
|
+
path: string = undefined,
|
|
9
|
+
dbc = "WaXCode.DBC",
|
|
10
|
+
) {
|
|
11
|
+
return EQ.PRE(equivalent, true, path, dbc);
|
|
12
|
+
}
|
|
13
|
+
/** See {@link COMPARISON.POST }. */
|
|
14
|
+
public static override POST(
|
|
15
|
+
equivalent,
|
|
16
|
+
invert = false,
|
|
17
|
+
path: string = undefined,
|
|
18
|
+
dbc = "WaXCode.DBC",
|
|
19
|
+
) {
|
|
20
|
+
return EQ.POST(equivalent, true, path, dbc);
|
|
21
|
+
}
|
|
22
|
+
/** See {@link COMPARISON.INVARIANT }. */
|
|
23
|
+
public static INVARIANT(
|
|
24
|
+
equivalent,
|
|
25
|
+
invert = false,
|
|
26
|
+
path: string = undefined,
|
|
27
|
+
dbc = "WaXCode.DBC",
|
|
28
|
+
) {
|
|
29
|
+
return EQ.INVARIANT(equivalent, true, path, dbc);
|
|
30
|
+
}
|
|
31
|
+
/** See {@link COMPARISON.constructor }. */
|
|
32
|
+
constructor(public equivalent) {
|
|
33
|
+
super(equivalent, true);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import { DBC } from "../DBC";
|
|
2
|
+
/**
|
|
3
|
+
* A {@link DBC } defining that a {@link HTMLElement } gotta have a certain attribute set.
|
|
4
|
+
*
|
|
5
|
+
* @remarks
|
|
6
|
+
* Maintainer: Callari, Salvatore (XDBC@WaXCode.net) */
|
|
7
|
+
export class HasAttribute extends DBC {
|
|
8
|
+
// #region Condition checking.
|
|
9
|
+
/**
|
|
10
|
+
* Checks if the {@link HTMLElement } **toCheck** has the attribute **toCheckFor**.
|
|
11
|
+
*
|
|
12
|
+
* @param toCheckFor name of the attribute to check for whether it is set or not.
|
|
13
|
+
*
|
|
14
|
+
* @returns TRUE if the {@link HTMLElement } **toCheck** has set the attribute **toCheckFor**,
|
|
15
|
+
* otherwise a proper errormessage. */
|
|
16
|
+
public static checkAlgorithm(
|
|
17
|
+
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
|
|
18
|
+
toCheck: any,
|
|
19
|
+
toCheckFor: string,
|
|
20
|
+
invert,
|
|
21
|
+
): boolean | string {
|
|
22
|
+
if(!( toCheck instanceof HTMLElement )) {
|
|
23
|
+
return `The object to check for whether it has the attribute "${ toCheckFor }" is not a HTMLElement. It is of type "${ typeof toCheck }".`;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
if (!invert && !( toCheck as HTMLElement ).hasAttribute( toCheckFor )) {
|
|
27
|
+
return `Required Attribute "${ toCheckFor }" is not set.`;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
if (invert && ( toCheck as HTMLElement ).hasAttribute( toCheckFor )) {
|
|
31
|
+
return `Forbidden Attribute "${ toCheckFor }" is set.`;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return true;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* A parameter-decorator factory using the {@link HasAttribute.checkAlgorithm } to determine whether this {@link DBC } is fulfilled
|
|
38
|
+
* by the tagged parameter.
|
|
39
|
+
*
|
|
40
|
+
* @param toCheckFor See {@link HasAttribute.checkAlgorithm }.
|
|
41
|
+
* @param path See {@link DBC.decPrecondition }.
|
|
42
|
+
* @param dbc See {@link DBC.decPrecondition }.
|
|
43
|
+
*
|
|
44
|
+
* @returns See {@link DBC.decPrecondition }. */
|
|
45
|
+
public static PRE(
|
|
46
|
+
toCheckFor: string,
|
|
47
|
+
invert = false,
|
|
48
|
+
path: string | undefined = undefined,
|
|
49
|
+
dbc = "WaXCode.DBC",
|
|
50
|
+
): (
|
|
51
|
+
target: object,
|
|
52
|
+
methodName: string | symbol,
|
|
53
|
+
parameterIndex: number,
|
|
54
|
+
) => void {
|
|
55
|
+
return DBC.decPrecondition(
|
|
56
|
+
(
|
|
57
|
+
value: object,
|
|
58
|
+
target: object,
|
|
59
|
+
methodName: string,
|
|
60
|
+
parameterIndex: number,
|
|
61
|
+
) => {
|
|
62
|
+
return HasAttribute.checkAlgorithm(value, toCheckFor, invert);
|
|
63
|
+
},
|
|
64
|
+
dbc,
|
|
65
|
+
path,
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* A method-decorator factory using the {@link HasAttribute.checkAlgorithm } to determine whether this {@link DBC } is
|
|
70
|
+
* fulfilled by the tagged method's returnvalue.
|
|
71
|
+
*
|
|
72
|
+
* @param toCheckFor See {@link HasAttribute.checkAlgorithm }.
|
|
73
|
+
* @param path See {@link DBC.Postcondition }.
|
|
74
|
+
* @param dbc See {@link DBC.decPostcondition }.
|
|
75
|
+
*
|
|
76
|
+
* @returns See {@link DBC.decPostcondition }. */
|
|
77
|
+
public static POST(
|
|
78
|
+
toCheckFor: string,
|
|
79
|
+
invert = false,
|
|
80
|
+
path: string | undefined = undefined,
|
|
81
|
+
dbc = "WaXCode.DBC",
|
|
82
|
+
): (
|
|
83
|
+
target: object,
|
|
84
|
+
propertyKey: string,
|
|
85
|
+
descriptor: PropertyDescriptor,
|
|
86
|
+
) => PropertyDescriptor {
|
|
87
|
+
return DBC.decPostcondition(
|
|
88
|
+
(value: object, target: object, propertyKey: string) => {
|
|
89
|
+
return HasAttribute.checkAlgorithm(value, toCheckFor, invert);
|
|
90
|
+
},
|
|
91
|
+
dbc,
|
|
92
|
+
path,
|
|
93
|
+
);
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* A field-decorator factory using the {@link hasAttribute.checkAlgorithm } to determine whether this {@link DBC } is
|
|
97
|
+
* fulfilled by the tagged field.
|
|
98
|
+
*
|
|
99
|
+
* @param toCheckFor See {@link hasAttribute.checkAlgorithm }.
|
|
100
|
+
* @param path See {@link DBC.decInvariant }.
|
|
101
|
+
* @param dbc See {@link DBC.decInvariant }.
|
|
102
|
+
*
|
|
103
|
+
* @returns See {@link DBC.decInvariant }. */
|
|
104
|
+
public static INVARIANT(
|
|
105
|
+
toCheckFor: any,
|
|
106
|
+
invert = false,
|
|
107
|
+
path: string | undefined = undefined,
|
|
108
|
+
dbc = "WaXCode.DBC",
|
|
109
|
+
) {
|
|
110
|
+
return DBC.decInvariant([new HasAttribute(toCheckFor, invert)], path, dbc);
|
|
111
|
+
}
|
|
112
|
+
// #endregion Condition checking.
|
|
113
|
+
// #region Referenced Condition checking.
|
|
114
|
+
//
|
|
115
|
+
// For usage in dynamic scenarios (like with AE-DBC).
|
|
116
|
+
//
|
|
117
|
+
/**
|
|
118
|
+
* Invokes the {@link hasAttribute.checkAlgorithm } passing the value **toCheck**, {@link hasAttribute.equivalent } and
|
|
119
|
+
* {@link hasAttribute.invert }.
|
|
120
|
+
*
|
|
121
|
+
* @param toCheck See {@link EQ.checkAlgorithm }.
|
|
122
|
+
*
|
|
123
|
+
* @returns See {@link EQ.checkAlgorithm}. */
|
|
124
|
+
// biome-ignore lint/suspicious/noExplicitAny: Necessary to check against NULL & UNDEFINED.
|
|
125
|
+
public check(toCheck: any) {
|
|
126
|
+
return HasAttribute.checkAlgorithm(toCheck, this.toCheckFor, this.invert);
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Creates this {@link DBC } by setting the protected property {@link hasAttribute.equivalent } used by
|
|
130
|
+
* {@link hasAttribute.check }.
|
|
131
|
+
*
|
|
132
|
+
* @param toCheckFor See {@link hasAttribute.check }. */
|
|
133
|
+
public constructor(
|
|
134
|
+
protected toCheckFor: string,
|
|
135
|
+
protected invert = false,
|
|
136
|
+
) {
|
|
137
|
+
super();
|
|
138
|
+
}
|
|
139
|
+
// #endregion Referenced Condition checking.
|
|
140
|
+
}
|
package/src/DBC/IF.ts
ADDED
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import { DBC } from "../DBC";
|
|
2
|
+
/**
|
|
3
|
+
* A {@link DBC } defining that an {@link object } has also to comply to a certain {@link DBC } if it complies to
|
|
4
|
+
* another specified one.
|
|
5
|
+
*
|
|
6
|
+
* @remarks
|
|
7
|
+
* Maintainer: Callari, Salvatore (XDBC@WaXCode.net) */
|
|
8
|
+
export class IF extends DBC {
|
|
9
|
+
// #region Condition checking.
|
|
10
|
+
/**
|
|
11
|
+
* Checks if the value **toCheck** complies to the specified **condition** and if so does also comply to the one **inCase**.
|
|
12
|
+
*
|
|
13
|
+
* @param toCheck The value that has to be equal to it's possible **equivalent** for this {@link DBC } to be fulfilled.
|
|
14
|
+
* @param condition The contract **toCheck** has to comply to in order to also have to comply to the one **inCase**.
|
|
15
|
+
* @param inCase The contract **toCheck** has to also comply to if it complies to **condition**.
|
|
16
|
+
*
|
|
17
|
+
* @returns TRUE if the value **toCheck** and the **equivalent** are equal to each other, otherwise FALSE. */
|
|
18
|
+
public static checkAlgorithm(
|
|
19
|
+
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
|
|
20
|
+
toCheck: any,
|
|
21
|
+
condition: {check: (toCheck: unknown | undefined | null | object) => boolean | string;},
|
|
22
|
+
inCase:{
|
|
23
|
+
check: (toCheck: unknown | undefined | null | object) => boolean | string;
|
|
24
|
+
},
|
|
25
|
+
invert,
|
|
26
|
+
): boolean | string {
|
|
27
|
+
if (!invert && condition.check(toCheck)&&!inCase.check(toCheck)) {
|
|
28
|
+
return `In case that the value complies to "${condition}" it also has to comply to "${inCase}"`;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
if (!invert && !condition.check(toCheck)&&!inCase.check(toCheck)) {
|
|
32
|
+
return `In case that the value does not comply to "${condition}" it has to comply to "${inCase}"`;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return true;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* A parameter-decorator factory using the {@link EQ.checkAlgorithm } to determine whether this {@link DBC } is fulfilled
|
|
39
|
+
* by the tagged parameter.
|
|
40
|
+
*
|
|
41
|
+
* @param condition See {@link IF.checkAlgorithm }.
|
|
42
|
+
* @param inCase See {@link IF.checkAlgorithm }.
|
|
43
|
+
* @param path See {@link DBC.decPrecondition }.
|
|
44
|
+
* @param dbc See {@link DBC.decPrecondition }.
|
|
45
|
+
*
|
|
46
|
+
* @returns See {@link DBC.decPrecondition }. */
|
|
47
|
+
public static PRE(
|
|
48
|
+
condition: {check: (toCheck: unknown | undefined | null | object) => boolean | string;},
|
|
49
|
+
inCase: {check: (toCheck: unknown | undefined | null | object) => boolean | string;},
|
|
50
|
+
invert = false,
|
|
51
|
+
path: string | undefined = undefined,
|
|
52
|
+
dbc = "WaXCode.DBC",
|
|
53
|
+
): (
|
|
54
|
+
target: object,
|
|
55
|
+
methodName: string | symbol,
|
|
56
|
+
parameterIndex: number,
|
|
57
|
+
) => void {
|
|
58
|
+
return DBC.decPrecondition(
|
|
59
|
+
(
|
|
60
|
+
value: object,
|
|
61
|
+
target: object,
|
|
62
|
+
methodName: string,
|
|
63
|
+
parameterIndex: number,
|
|
64
|
+
) => {
|
|
65
|
+
return IF.checkAlgorithm(value, condition, inCase, invert);
|
|
66
|
+
},
|
|
67
|
+
dbc,
|
|
68
|
+
path,
|
|
69
|
+
);
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* A method-decorator factory using the {@link IF.checkAlgorithm } to determine whether this {@link DBC } is fulfilled
|
|
73
|
+
* by the tagged method's returnvalue.
|
|
74
|
+
*
|
|
75
|
+
* @param condition See {@link IF.checkAlgorithm }.
|
|
76
|
+
* @param inCase See {@link IF.checkAlgorithm }.
|
|
77
|
+
* @param path See {@link DBC.Postcondition }.
|
|
78
|
+
* @param dbc See {@link DBC.decPostcondition }.
|
|
79
|
+
*
|
|
80
|
+
* @returns See {@link DBC.decPostcondition }. */
|
|
81
|
+
public static POST(
|
|
82
|
+
condition: {check: (toCheck: unknown | undefined | null | object) => boolean | string;},
|
|
83
|
+
inCase: {check: (toCheck: unknown | undefined | null | object) => boolean | string;},
|
|
84
|
+
invert = false,
|
|
85
|
+
path: string | undefined = undefined,
|
|
86
|
+
dbc = "WaXCode.DBC",
|
|
87
|
+
): (
|
|
88
|
+
target: object,
|
|
89
|
+
propertyKey: string,
|
|
90
|
+
descriptor: PropertyDescriptor,
|
|
91
|
+
) => PropertyDescriptor {
|
|
92
|
+
return DBC.decPostcondition(
|
|
93
|
+
(value: object, target: object, propertyKey: string) => {
|
|
94
|
+
return IF.checkAlgorithm(value, condition, inCase, invert);
|
|
95
|
+
},
|
|
96
|
+
dbc,
|
|
97
|
+
path,
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* A field-decorator factory using the {@link IF.checkAlgorithm } to determine whether this {@link DBC } is fulfilled
|
|
102
|
+
* by the tagged field.
|
|
103
|
+
*
|
|
104
|
+
* @param condition See {@link IF.checkAlgorithm }.
|
|
105
|
+
* @param inCase See {@link IF.checkAlgorithm }.
|
|
106
|
+
* @param path See {@link DBC.decInvariant }.
|
|
107
|
+
* @param dbc See {@link DBC.decInvariant }.
|
|
108
|
+
*
|
|
109
|
+
* @returns See {@link DBC.decInvariant }. */
|
|
110
|
+
public static INVARIANT(
|
|
111
|
+
condition: {check: (toCheck: unknown | undefined | null | object) => boolean | string;},
|
|
112
|
+
inCase: {check: (toCheck: unknown | undefined | null | object) => boolean | string;},
|
|
113
|
+
invert = false,
|
|
114
|
+
path: string | undefined = undefined,
|
|
115
|
+
dbc = "WaXCode.DBC",
|
|
116
|
+
) {
|
|
117
|
+
return DBC.decInvariant([new IF(condition, inCase, invert)], path, dbc);
|
|
118
|
+
}
|
|
119
|
+
// #endregion Condition checking.
|
|
120
|
+
// #region Referenced Condition checking.
|
|
121
|
+
//
|
|
122
|
+
// For usage in dynamic scenarios (like with AE-DBC).
|
|
123
|
+
//
|
|
124
|
+
/**
|
|
125
|
+
* Invokes the {@link IF.checkAlgorithm } passing the value **toCheck**, {@link IF.equivalent } and {@link IF.invert }.
|
|
126
|
+
*
|
|
127
|
+
* @param toCheck See {@link IF.checkAlgorithm }.
|
|
128
|
+
*
|
|
129
|
+
* @returns See {@link IF.checkAlgorithm}. */
|
|
130
|
+
// biome-ignore lint/suspicious/noExplicitAny: Necessary to check against NULL & UNDEFINED.
|
|
131
|
+
public check(toCheck: any) {
|
|
132
|
+
return IF.checkAlgorithm(toCheck, this.condition, this.inCase, this.invert);
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Creates this {@link IF } by setting the protected property {@link IF.equivalent } used by {@link IF.check }.
|
|
136
|
+
*
|
|
137
|
+
* @param equivalent See {@link IF.check }. */
|
|
138
|
+
public constructor(
|
|
139
|
+
// biome-ignore lint/suspicious/noExplicitAny: To be able to match UNDEFINED and NULL.
|
|
140
|
+
protected condition: {check: (toCheck: unknown | undefined | null | object) => boolean | string;},
|
|
141
|
+
protected inCase: {check: (toCheck: unknown | undefined | null | object) => boolean | string;},
|
|
142
|
+
protected invert = false,
|
|
143
|
+
) {
|
|
144
|
+
super();
|
|
145
|
+
}
|
|
146
|
+
// #endregion Referenced Condition checking.
|
|
147
|
+
}
|
package/src/DBC.ts
CHANGED
|
@@ -141,11 +141,20 @@ export class DBC {
|
|
|
141
141
|
dbc = "WaXCode.DBC",
|
|
142
142
|
) {
|
|
143
143
|
return (target: unknown, propertyKey: string | symbol) => {
|
|
144
|
+
if (!DBC.resolveDBCPath(window, dbc).executionSettings.checkInvariants) {
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
144
147
|
// biome-ignore lint/suspicious/noExplicitAny: Necessary to intercept UNDEFINED and NULL.
|
|
145
148
|
let value: any;
|
|
146
149
|
// #region Replace original property.
|
|
147
150
|
Object.defineProperty(target, propertyKey, {
|
|
148
151
|
set(newValue) {
|
|
152
|
+
if (
|
|
153
|
+
!DBC.resolveDBCPath(window, dbc).executionSettings.checkInvariants
|
|
154
|
+
) {
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
|
|
149
158
|
const realValue = path ? DBC.resolve(newValue, path) : newValue;
|
|
150
159
|
// #region Check if all "contracts" are fulfilled.
|
|
151
160
|
for (const contract of contracts) {
|
|
@@ -196,6 +205,11 @@ export class DBC {
|
|
|
196
205
|
const originalMethod = descriptor.value;
|
|
197
206
|
// biome-ignore lint/suspicious/noExplicitAny: Necessary to intercept UNDEFINED and NULL.
|
|
198
207
|
descriptor.value = (...args: any[]) => {
|
|
208
|
+
if (
|
|
209
|
+
!DBC.resolveDBCPath(window, dbc).executionSettings.checkPostconditions
|
|
210
|
+
) {
|
|
211
|
+
return;
|
|
212
|
+
}
|
|
199
213
|
// biome-ignore lint/complexity/noThisInStatic: <explanation>
|
|
200
214
|
const result = originalMethod.apply(this, args);
|
|
201
215
|
const realValue = path ? DBC.resolve(result, path) : result;
|
|
@@ -249,6 +263,13 @@ export class DBC {
|
|
|
249
263
|
methodName,
|
|
250
264
|
parameterIndex,
|
|
251
265
|
(value: unknown) => {
|
|
266
|
+
if (
|
|
267
|
+
!DBC.resolveDBCPath(window, dbc).executionSettings
|
|
268
|
+
.checkPreconditions
|
|
269
|
+
) {
|
|
270
|
+
return;
|
|
271
|
+
}
|
|
272
|
+
|
|
252
273
|
const realValue = path ? DBC.resolve(value, path) : value;
|
|
253
274
|
const result = check(realValue, target, methodName, parameterIndex);
|
|
254
275
|
|
|
@@ -268,6 +289,18 @@ export class DBC {
|
|
|
268
289
|
}
|
|
269
290
|
// #endregion Precondition
|
|
270
291
|
// #endregion Decorator
|
|
292
|
+
// #region Execution Handling
|
|
293
|
+
/** Stores settings concerning the execution of checks. */
|
|
294
|
+
public executionSettings: {
|
|
295
|
+
checkPreconditions: boolean;
|
|
296
|
+
checkPostconditions: boolean;
|
|
297
|
+
checkInvariants: boolean;
|
|
298
|
+
} = {
|
|
299
|
+
checkPreconditions: true,
|
|
300
|
+
checkPostconditions: true,
|
|
301
|
+
checkInvariants: true,
|
|
302
|
+
};
|
|
303
|
+
// #endregion Execution Handling
|
|
271
304
|
// #region Warning handling.
|
|
272
305
|
/** Stores settings concerning warnings. */
|
|
273
306
|
public warningSettings: {
|
|
@@ -412,12 +445,22 @@ export class DBC {
|
|
|
412
445
|
* Constructs this {@link DBC } by setting the {@link DBC.infringementSettings }, define the **WaXCode** namespace in
|
|
413
446
|
* **window** if not yet available and setting the property **DBC** in there to the instance of this {@link DBC }.
|
|
414
447
|
*
|
|
415
|
-
* @param infringementSettings
|
|
448
|
+
* @param infringementSettings See {@link DBC.infringementSettings }.
|
|
449
|
+
* @param executionSettings See {@link DBC.executionSettings }. */
|
|
416
450
|
constructor(
|
|
417
451
|
infringementSettings: {
|
|
418
452
|
throwException: boolean;
|
|
419
453
|
logToConsole: boolean;
|
|
420
454
|
} = { throwException: true, logToConsole: false },
|
|
455
|
+
executionSettings: {
|
|
456
|
+
checkPreconditions: boolean;
|
|
457
|
+
checkPostconditions: boolean;
|
|
458
|
+
checkInvariants: boolean;
|
|
459
|
+
} = {
|
|
460
|
+
checkPreconditions: true,
|
|
461
|
+
checkPostconditions: true,
|
|
462
|
+
checkInvariants: true,
|
|
463
|
+
},
|
|
421
464
|
) {
|
|
422
465
|
this.infringementSettings = infringementSettings;
|
|
423
466
|
|