@theqrl/hypc 0.0.2 → 0.3.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/README.md +62 -15
- package/abi.js +17 -7
- package/bindings/compile.js +158 -31
- package/bindings/core.js +22 -6
- package/bindings/helpers.js +3 -4
- package/bindings/index.js +13 -6
- package/common/helpers.js +17 -3
- package/downloadCurrentVersion.js +20 -14
- package/formatters.js +2 -3
- package/hypc.js +91 -35
- package/hypjson.js +110 -1732
- package/linker.js +63 -32
- package/package.json +28 -28
- package/smtchecker.js +3 -1
- package/smtsolver.js +44 -17
- package/translate.js +4 -4
- package/verifyVersion.js +17 -7
- package/wrapper.js +305 -30
- package/build/clean.js +0 -6
- package/build/pack-publish-block.js +0 -10
- package/build/postbuild.js +0 -3
- package/contractA_hyp_A.bin +0 -1
- package/contractB_hyp_B.bin +0 -1
- package/importA_hyp_C.bin +0 -1
- package/importB_hyp_D.bin +0 -1
- package/libX_hyp_X.bin +0 -1
- package/libY_hyp_Y.bin +0 -1
- package/libZ_hyp_Z.bin +0 -1
- package/test/abi.js +0 -77
- package/test/cli.js +0 -245
- package/test/compiler.js +0 -791
- package/test/index.js +0 -36
- package/test/linker.js +0 -132
- package/test/resources/fixtureAsmJson.hyp +0 -8
- package/test/resources/fixtureAsmJson.json +0 -528
- package/test/resources/fixtureAsmJson.output +0 -101
- package/test/resources/fixtureIncorrectSource.hyp +0 -1
- package/test/resources/fixtureSmoke.hyp +0 -5
- package/test/resources/importA.hyp +0 -7
- package/test/resources/importB.hyp +0 -5
- package/test/resources/importCallback/base/contractA.hyp +0 -8
- package/test/resources/importCallback/base/contractB.hyp +0 -6
- package/test/resources/importCallback/contractC.hyp +0 -4
- package/test/resources/importCallback/includeA/libX.hyp +0 -4
- package/test/resources/importCallback/includeA/libY.hyp +0 -6
- package/test/resources/importCallback/includeA/utils.hyp +0 -4
- package/test/resources/importCallback/includeB/libZ.hyp +0 -4
- package/test/resources/smtChecker/loop.hyp +0 -8
- package/test/resources/smtChecker/smoke.hyp +0 -5
- package/test/resources/smtChecker/smoke_with_engine.hyp +0 -6
- package/test/resources/smtChecker/smoke_with_multi_engine.hyp +0 -8
- package/test/smtcallback.js +0 -221
- package/test/smtchecker.js +0 -83
- package/test/translate.js +0 -83
- package/test_resources_fixtureSmoke_hyp_C.abi +0 -1
- package/test_resources_fixtureSmoke_hyp_C.bin +0 -1
- package/test_resources_importA_hyp_C.bin +0 -1
- package/test_resources_importB_hyp_D.bin +0 -1
- package/tsconfig.json +0 -25
- package/utils_hyp_Utils.bin +0 -1
package/test/cli.js
DELETED
|
@@ -1,245 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
-
};
|
|
28
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
const tape_1 = __importDefault(require("tape"));
|
|
30
|
-
const tape_spawn_1 = __importDefault(require("tape-spawn"));
|
|
31
|
-
const path = __importStar(require("path"));
|
|
32
|
-
const __1 = __importDefault(require("../"));
|
|
33
|
-
(0, tape_1.default)('CLI', function (t) {
|
|
34
|
-
t.test('--version', function (st) {
|
|
35
|
-
const spt = (0, tape_spawn_1.default)(st, './hypc.js --version');
|
|
36
|
-
spt.stdout.match(__1.default.version() + '\n');
|
|
37
|
-
spt.stdout.match(/^\s*[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9.]+)?\+commit\.[0-9a-f]+([a-zA-Z0-9.-]+)?\s*$/);
|
|
38
|
-
spt.stderr.empty();
|
|
39
|
-
spt.end();
|
|
40
|
-
});
|
|
41
|
-
t.test('no parameters', function (st) {
|
|
42
|
-
const spt = (0, tape_spawn_1.default)(st, './hypc.js');
|
|
43
|
-
spt.stderr.match(/^Must provide a file/);
|
|
44
|
-
spt.end();
|
|
45
|
-
});
|
|
46
|
-
t.test('no mode specified', function (st) {
|
|
47
|
-
const spt = (0, tape_spawn_1.default)(st, './hypc.js test/resources/fixtureSmoke.hyp');
|
|
48
|
-
spt.stderr.match(/^Invalid option selected/);
|
|
49
|
-
spt.end();
|
|
50
|
-
});
|
|
51
|
-
t.test('--bin', function (st) {
|
|
52
|
-
const spt = (0, tape_spawn_1.default)(st, './hypc.js --bin test/resources/fixtureSmoke.hyp');
|
|
53
|
-
spt.stderr.empty();
|
|
54
|
-
spt.succeeds();
|
|
55
|
-
spt.end();
|
|
56
|
-
});
|
|
57
|
-
t.test('--bin --optimize', function (st) {
|
|
58
|
-
const spt = (0, tape_spawn_1.default)(st, './hypc.js --bin --optimize test/resources/fixtureSmoke.hyp');
|
|
59
|
-
spt.stderr.empty();
|
|
60
|
-
spt.succeeds();
|
|
61
|
-
spt.end();
|
|
62
|
-
});
|
|
63
|
-
t.test('--bin --optimize-runs 666', function (st) {
|
|
64
|
-
const spt = (0, tape_spawn_1.default)(st, './hypc.js --bin --optimize-runs 666 test/resources/fixtureSmoke.hyp');
|
|
65
|
-
spt.stderr.empty();
|
|
66
|
-
spt.succeeds();
|
|
67
|
-
spt.end();
|
|
68
|
-
});
|
|
69
|
-
t.test('--bin --optimize-runs not-a-number', function (st) {
|
|
70
|
-
const spt = (0, tape_spawn_1.default)(st, './hypc.js --bin --optimize-runs not-a-number test/resources/fixtureSmoke.hyp');
|
|
71
|
-
spt.stderr.match(/^error: option '--optimize-runs <optimize-runs>' argument 'not-a-number' is invalid/);
|
|
72
|
-
spt.end();
|
|
73
|
-
});
|
|
74
|
-
t.test('invalid file specified', function (st) {
|
|
75
|
-
const spt = (0, tape_spawn_1.default)(st, './hypc.js --bin test/fileNotFound.hyp');
|
|
76
|
-
spt.stderr.match(/^Error reading /);
|
|
77
|
-
spt.end();
|
|
78
|
-
});
|
|
79
|
-
t.test('incorrect source source', function (st) {
|
|
80
|
-
const spt = (0, tape_spawn_1.default)(st, './hypc.js --bin test/resources/fixtureIncorrectSource.hyp');
|
|
81
|
-
spt.stderr.match(/SyntaxError: Invalid pragma "contract"/);
|
|
82
|
-
spt.end();
|
|
83
|
-
});
|
|
84
|
-
t.test('--abi', function (st) {
|
|
85
|
-
const spt = (0, tape_spawn_1.default)(st, './hypc.js --abi test/resources/fixtureSmoke.hyp');
|
|
86
|
-
spt.stderr.empty();
|
|
87
|
-
spt.succeeds();
|
|
88
|
-
spt.end();
|
|
89
|
-
});
|
|
90
|
-
t.test('--bin --abi', function (st) {
|
|
91
|
-
const spt = (0, tape_spawn_1.default)(st, './hypc.js --bin --abi test/resources/fixtureSmoke.hyp');
|
|
92
|
-
spt.stderr.empty();
|
|
93
|
-
spt.succeeds();
|
|
94
|
-
spt.end();
|
|
95
|
-
});
|
|
96
|
-
t.test('no base path', function (st) {
|
|
97
|
-
const spt = (0, tape_spawn_1.default)(st, './hypc.js --bin ' +
|
|
98
|
-
'test/resources/importA.hyp ' +
|
|
99
|
-
'./test/resources//importA.hyp ' +
|
|
100
|
-
path.resolve('test/resources/importA.hyp'));
|
|
101
|
-
spt.stderr.empty();
|
|
102
|
-
spt.succeeds();
|
|
103
|
-
spt.end();
|
|
104
|
-
});
|
|
105
|
-
t.test('relative base path', function (st) {
|
|
106
|
-
// NOTE: This and other base path tests rely on the relative ./importB.hyp import in importA.hyp.
|
|
107
|
-
// If base path is not stripped correctly from all source paths below, they will not be found
|
|
108
|
-
// by the import callback when it appends the base path back.
|
|
109
|
-
const spt = (0, tape_spawn_1.default)(st, './hypc.js --bin --base-path test/resources ' +
|
|
110
|
-
'test/resources/importA.hyp ' +
|
|
111
|
-
'./test/resources//importA.hyp ' +
|
|
112
|
-
path.resolve('test/resources/importA.hyp'));
|
|
113
|
-
spt.stderr.empty();
|
|
114
|
-
spt.succeeds();
|
|
115
|
-
spt.end();
|
|
116
|
-
});
|
|
117
|
-
t.test('relative non canonical base path', function (st) {
|
|
118
|
-
const spt = (0, tape_spawn_1.default)(st, './hypc.js --bin --base-path ./test/resources ' +
|
|
119
|
-
'test/resources/importA.hyp ' +
|
|
120
|
-
'./test/resources//importA.hyp ' +
|
|
121
|
-
path.resolve('test/resources/importA.hyp'));
|
|
122
|
-
spt.stderr.empty();
|
|
123
|
-
spt.succeeds();
|
|
124
|
-
spt.end();
|
|
125
|
-
});
|
|
126
|
-
t.test('absolute base path', function (st) {
|
|
127
|
-
const spt = (0, tape_spawn_1.default)(st, './hypc.js --bin --base-path ' + path.resolve('test/resources') + ' ' +
|
|
128
|
-
'test/resources/importA.hyp ' +
|
|
129
|
-
'./test/resources//importA.hyp ' +
|
|
130
|
-
path.resolve('test/resources/importA.hyp'));
|
|
131
|
-
spt.stderr.empty();
|
|
132
|
-
spt.succeeds();
|
|
133
|
-
spt.end();
|
|
134
|
-
});
|
|
135
|
-
t.test('include paths', function (st) {
|
|
136
|
-
const spt = (0, tape_spawn_1.default)(st, './hypc.js --bin ' +
|
|
137
|
-
'test/resources/importCallback/base/contractB.hyp ' +
|
|
138
|
-
'test/resources/importCallback/includeA/libY.hyp ' +
|
|
139
|
-
'./test/resources/importCallback/includeA//libY.hyp ' +
|
|
140
|
-
path.resolve('test/resources/importCallback/includeA/libY.hyp') + ' ' +
|
|
141
|
-
'--base-path test/resources/importCallback/base ' +
|
|
142
|
-
'--include-path test/resources/importCallback/includeA ' +
|
|
143
|
-
'--include-path ' + path.resolve('test/resources/importCallback/includeB/'));
|
|
144
|
-
spt.stderr.empty();
|
|
145
|
-
spt.succeeds();
|
|
146
|
-
spt.end();
|
|
147
|
-
});
|
|
148
|
-
t.test('include paths without base path', function (st) {
|
|
149
|
-
const spt = (0, tape_spawn_1.default)(st, './hypc.js --bin ' +
|
|
150
|
-
'test/resources/importCallback/contractC.hyp ' +
|
|
151
|
-
'--include-path test/resources/importCallback/includeA');
|
|
152
|
-
spt.stderr.match(/--include-path option requires a non-empty base path\./);
|
|
153
|
-
spt.fails();
|
|
154
|
-
spt.end();
|
|
155
|
-
});
|
|
156
|
-
t.test('empty include paths', function (st) {
|
|
157
|
-
const spt = (0, tape_spawn_1.default)(st, './hypc.js --bin ' +
|
|
158
|
-
'test/resources/importCallback/contractC.hyp ' +
|
|
159
|
-
'--base-path test/resources/importCallback/base ' +
|
|
160
|
-
'--include-path=');
|
|
161
|
-
spt.stderr.match(/Empty values are not allowed in --include-path\./);
|
|
162
|
-
spt.fails();
|
|
163
|
-
spt.end();
|
|
164
|
-
});
|
|
165
|
-
t.test('standard json', function (st) {
|
|
166
|
-
const input = {
|
|
167
|
-
language: 'Hyperion',
|
|
168
|
-
settings: {
|
|
169
|
-
outputSelection: {
|
|
170
|
-
'*': {
|
|
171
|
-
'*': ['zvm.bytecode', 'userdoc']
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
},
|
|
175
|
-
sources: {
|
|
176
|
-
'Contract.hyp': {
|
|
177
|
-
content: 'pragma hyperion >=0.0.1; contract Contract { function f() pure public {} }'
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
};
|
|
181
|
-
const spt = (0, tape_spawn_1.default)(st, './hypc.js --standard-json');
|
|
182
|
-
spt.stdin.setEncoding('utf-8');
|
|
183
|
-
spt.stdin.write(JSON.stringify(input));
|
|
184
|
-
spt.stdin.end();
|
|
185
|
-
spt.stdin.on('finish', function () {
|
|
186
|
-
spt.stderr.empty();
|
|
187
|
-
spt.stdout.match(/Contract.hyp/);
|
|
188
|
-
spt.stdout.match(/userdoc/);
|
|
189
|
-
spt.succeeds();
|
|
190
|
-
spt.end();
|
|
191
|
-
});
|
|
192
|
-
});
|
|
193
|
-
t.test('standard json base path', function (st) {
|
|
194
|
-
const input = {
|
|
195
|
-
language: 'Hyperion',
|
|
196
|
-
settings: {
|
|
197
|
-
outputSelection: {
|
|
198
|
-
'*': {
|
|
199
|
-
'*': ['metadata']
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
},
|
|
203
|
-
sources: {
|
|
204
|
-
'importA.hyp': {
|
|
205
|
-
content: 'import "./importB.hyp";'
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
};
|
|
209
|
-
const spt = (0, tape_spawn_1.default)(st, './hypc.js --standard-json --base-path test/resources');
|
|
210
|
-
spt.stdin.setEncoding('utf-8');
|
|
211
|
-
spt.stdin.write(JSON.stringify(input));
|
|
212
|
-
spt.stdin.end();
|
|
213
|
-
spt.stdin.on('finish', function () {
|
|
214
|
-
spt.stderr.empty();
|
|
215
|
-
spt.stdout.match(/{"contracts":{"importB.hyp":{"D":{"metadata":/);
|
|
216
|
-
spt.succeeds();
|
|
217
|
-
spt.end();
|
|
218
|
-
});
|
|
219
|
-
});
|
|
220
|
-
t.test('standard json include paths', function (st) {
|
|
221
|
-
const input = {
|
|
222
|
-
language: 'Hyperion',
|
|
223
|
-
sources: {
|
|
224
|
-
'contractB.hyp': {
|
|
225
|
-
content: '// SPDX-License-Identifier: GPL-3.0\n' +
|
|
226
|
-
'pragma hyperion >=0.0.1;\n' +
|
|
227
|
-
'import "./contractA.hyp";\n'
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
};
|
|
231
|
-
const spt = (0, tape_spawn_1.default)(st, './hypc.js --standard-json ' +
|
|
232
|
-
'--base-path test/resources/importCallback/base ' +
|
|
233
|
-
'--include-path test/resources/importCallback/includeA ' +
|
|
234
|
-
'--include-path ' + path.resolve('test/resources/importCallback/includeB/'));
|
|
235
|
-
spt.stdin.setEncoding('utf-8');
|
|
236
|
-
spt.stdin.write(JSON.stringify(input));
|
|
237
|
-
spt.stdin.end();
|
|
238
|
-
spt.stdin.on('finish', function () {
|
|
239
|
-
spt.stderr.empty();
|
|
240
|
-
spt.stdout.match(/"sources":{"contractA.hyp":{"id":0},"contractB.hyp":{"id":1},"libX.hyp":{"id":2},"libY.hyp":{"id":3},"libZ.hyp":{"id":4},"utils.hyp":{"id":5}}}/);
|
|
241
|
-
spt.succeeds();
|
|
242
|
-
spt.end();
|
|
243
|
-
});
|
|
244
|
-
});
|
|
245
|
-
});
|