smiles-js 2.1.0 → 2.2.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.
Files changed (34) hide show
  1. package/docs/smiles.peggy +215 -0
  2. package/package.json +1 -1
  3. package/src/decompiler.js +209 -49
  4. package/src/decompiler.test.js +232 -60
  5. package/src/fragment.test.js +7 -2
  6. package/src/method-attachers.js +8 -8
  7. package/test-integration/__snapshots__/acetaminophen.test.js.snap +20 -0
  8. package/test-integration/__snapshots__/adjuvant-analgesics.test.js.snap +62 -0
  9. package/test-integration/__snapshots__/cholesterol-drugs.test.js.snap +261 -0
  10. package/test-integration/__snapshots__/dexamethasone.test.js.snap +31 -0
  11. package/test-integration/__snapshots__/endocannabinoids.test.js.snap +77 -0
  12. package/test-integration/__snapshots__/endogenous-opioids.test.js.snap +1116 -0
  13. package/test-integration/__snapshots__/hypertension-medication.test.js.snap +69 -0
  14. package/test-integration/__snapshots__/local-anesthetics.test.js.snap +97 -0
  15. package/test-integration/__snapshots__/nsaids-otc.test.js.snap +60 -0
  16. package/test-integration/__snapshots__/nsaids-prescription.test.js.snap +113 -0
  17. package/test-integration/__snapshots__/opioids.test.js.snap +109 -0
  18. package/test-integration/__snapshots__/steroids.test.js.snap +379 -0
  19. package/test-integration/acetaminophen.test.js +15 -3
  20. package/test-integration/adjuvant-analgesics.test.js +43 -7
  21. package/test-integration/cholesterol-drugs.test.js +88 -22
  22. package/test-integration/dexamethasone.test.js +8 -2
  23. package/test-integration/endocannabinoids.test.js +48 -12
  24. package/test-integration/endogenous-opioids.smiles.js +32 -0
  25. package/test-integration/endogenous-opioids.test.js +192 -0
  26. package/test-integration/hypertension-medication.test.js +32 -8
  27. package/test-integration/local-anesthetics.smiles.js +33 -0
  28. package/test-integration/local-anesthetics.test.js +64 -16
  29. package/test-integration/nsaids-otc.test.js +40 -10
  30. package/test-integration/nsaids-prescription.test.js +72 -18
  31. package/test-integration/opioids.test.js +56 -14
  32. package/test-integration/steroids.test.js +112 -28
  33. package/test-integration/utils.js +4 -2
  34. package/todo +2 -1
@@ -19,6 +19,12 @@ describe('Acetaminophen Integration Test', () => {
19
19
  expect(code).toMatchSnapshot();
20
20
  });
21
21
 
22
+ test('generates valid verbose code via toCode()', () => {
23
+ const ast = parse(ACETAMINOPHEN_SMILES);
24
+ const code = ast.toCode('v', { verbose: true });
25
+ expect(code).toMatchSnapshot();
26
+ });
27
+
22
28
  test('generated code is valid JavaScript', () => {
23
29
  const ast = parse(ACETAMINOPHEN_SMILES);
24
30
  const code = ast.toCode('v');
@@ -26,14 +32,14 @@ describe('Acetaminophen Integration Test', () => {
26
32
 
27
33
  let factory;
28
34
  expect(() => {
29
- factory = createFunction('Ring', 'Linear', 'FusedRing', 'Molecule', executableCode);
35
+ factory = createFunction('Ring', 'Linear', 'FusedRing', 'Molecule', 'RawFragment', 'Fragment', executableCode);
30
36
  }).not.toThrow();
31
37
  expect(typeof factory).toBe('function');
32
38
  });
33
39
 
34
40
  test('codegen round-trip: generated code produces valid SMILES', () => {
35
41
  const ast = parse(ACETAMINOPHEN_SMILES);
36
- const code = ast.toCode('v');
42
+ const code = ast.toCode('v', { verbose: true });
37
43
  const executableCode = stripExports(code);
38
44
 
39
45
  const varMatch = code.match(/export const (v\d+) = /g);
@@ -59,9 +65,15 @@ describe('Phenacetin Integration Test', () => {
59
65
  expect(code).toMatchSnapshot();
60
66
  });
61
67
 
68
+ test('generates valid verbose code via toCode()', () => {
69
+ const ast = parse(PHENACETIN_SMILES);
70
+ const code = ast.toCode('v', { verbose: true });
71
+ expect(code).toMatchSnapshot();
72
+ });
73
+
62
74
  test('codegen round-trip: generated code produces valid SMILES', () => {
63
75
  const ast = parse(PHENACETIN_SMILES);
64
- const code = ast.toCode('v');
76
+ const code = ast.toCode('v', { verbose: true });
65
77
  const executableCode = stripExports(code);
66
78
 
67
79
  const varMatch = code.match(/export const (v\d+) = /g);
@@ -23,6 +23,12 @@ describe('Gabapentin Integration Test', () => {
23
23
  expect(code).toMatchSnapshot();
24
24
  });
25
25
 
26
+ test('generates valid verbose code via toCode()', () => {
27
+ const ast = parse(GABAPENTIN_SMILES);
28
+ const code = ast.toCode('v', { verbose: true });
29
+ expect(code).toMatchSnapshot();
30
+ });
31
+
26
32
  test('generated code is valid JavaScript', () => {
27
33
  const ast = parse(GABAPENTIN_SMILES);
28
34
  const code = ast.toCode('v');
@@ -30,14 +36,14 @@ describe('Gabapentin Integration Test', () => {
30
36
 
31
37
  let factory;
32
38
  expect(() => {
33
- factory = createFunction('Ring', 'Linear', 'FusedRing', 'Molecule', executableCode);
39
+ factory = createFunction('Ring', 'Linear', 'FusedRing', 'Molecule', 'RawFragment', 'Fragment', executableCode);
34
40
  }).not.toThrow();
35
41
  expect(typeof factory).toBe('function');
36
42
  });
37
43
 
38
44
  test('codegen round-trip: generated code produces valid SMILES', () => {
39
45
  const ast = parse(GABAPENTIN_SMILES);
40
- const code = ast.toCode('v');
46
+ const code = ast.toCode('v', { verbose: true });
41
47
  const executableCode = stripExports(code);
42
48
 
43
49
  const varMatch = code.match(/export const (v\d+) = /g);
@@ -64,9 +70,15 @@ describe('Pregabalin Integration Test', () => {
64
70
  expect(code).toMatchSnapshot();
65
71
  });
66
72
 
73
+ test('generates valid verbose code via toCode()', () => {
74
+ const ast = parse(PREGABALIN_SMILES);
75
+ const code = ast.toCode('v', { verbose: true });
76
+ expect(code).toMatchSnapshot();
77
+ });
78
+
67
79
  test('codegen round-trip: generated code produces valid SMILES', () => {
68
80
  const ast = parse(PREGABALIN_SMILES);
69
- const code = ast.toCode('v');
81
+ const code = ast.toCode('v', { verbose: true });
70
82
  const executableCode = stripExports(code);
71
83
 
72
84
  const varMatch = code.match(/export const (v\d+) = /g);
@@ -92,9 +104,15 @@ describe('Amitriptyline Integration Test', () => {
92
104
  expect(code).toMatchSnapshot();
93
105
  });
94
106
 
107
+ test('generates valid verbose code via toCode()', () => {
108
+ const ast = parse(AMITRIPTYLINE_SMILES);
109
+ const code = ast.toCode('v', { verbose: true });
110
+ expect(code).toMatchSnapshot();
111
+ });
112
+
95
113
  test('codegen round-trip: generated code produces valid SMILES', () => {
96
114
  const ast = parse(AMITRIPTYLINE_SMILES);
97
- const code = ast.toCode('v');
115
+ const code = ast.toCode('v', { verbose: true });
98
116
  const executableCode = stripExports(code);
99
117
 
100
118
  const varMatch = code.match(/export const (v\d+) = /g);
@@ -121,9 +139,15 @@ describe('Duloxetine Integration Test', () => {
121
139
  expect(code).toMatchSnapshot();
122
140
  });
123
141
 
142
+ test('generates valid verbose code via toCode()', () => {
143
+ const ast = parse(DULOXETINE_SMILES);
144
+ const code = ast.toCode('v', { verbose: true });
145
+ expect(code).toMatchSnapshot();
146
+ });
147
+
124
148
  test('codegen round-trip: generated code produces valid SMILES', () => {
125
149
  const ast = parse(DULOXETINE_SMILES);
126
- const code = ast.toCode('v');
150
+ const code = ast.toCode('v', { verbose: true });
127
151
  const executableCode = stripExports(code);
128
152
 
129
153
  const varMatch = code.match(/export const (v\d+) = /g);
@@ -150,9 +174,15 @@ describe('Carbamazepine Integration Test', () => {
150
174
  expect(code).toMatchSnapshot();
151
175
  });
152
176
 
177
+ test('generates valid verbose code via toCode()', () => {
178
+ const ast = parse(CARBAMAZEPINE_SMILES);
179
+ const code = ast.toCode('v', { verbose: true });
180
+ expect(code).toMatchSnapshot();
181
+ });
182
+
153
183
  test('codegen round-trip: generated code produces valid SMILES', () => {
154
184
  const ast = parse(CARBAMAZEPINE_SMILES);
155
- const code = ast.toCode('v');
185
+ const code = ast.toCode('v', { verbose: true });
156
186
  const executableCode = stripExports(code);
157
187
 
158
188
  const varMatch = code.match(/export const (v\d+) = /g);
@@ -179,9 +209,15 @@ describe('Valproic Acid Integration Test', () => {
179
209
  expect(code).toMatchSnapshot();
180
210
  });
181
211
 
212
+ test('generates valid verbose code via toCode()', () => {
213
+ const ast = parse(VALPROIC_ACID_SMILES);
214
+ const code = ast.toCode('v', { verbose: true });
215
+ expect(code).toMatchSnapshot();
216
+ });
217
+
182
218
  test('codegen round-trip: generated code produces valid SMILES', () => {
183
219
  const ast = parse(VALPROIC_ACID_SMILES);
184
- const code = ast.toCode('v');
220
+ const code = ast.toCode('v', { verbose: true });
185
221
  const executableCode = stripExports(code);
186
222
 
187
223
  const varMatch = code.match(/export const (v\d+) = /g);
@@ -28,6 +28,12 @@ describe('Atorvastatin Integration Test', () => {
28
28
  expect(code).toMatchSnapshot();
29
29
  });
30
30
 
31
+ test('generates valid verbose code via toCode()', () => {
32
+ const ast = parse(ATORVASTATIN_SMILES);
33
+ const code = ast.toCode('v', { verbose: true });
34
+ expect(code).toMatchSnapshot();
35
+ });
36
+
31
37
  test('generated code is valid JavaScript', () => {
32
38
  const ast = parse(ATORVASTATIN_SMILES);
33
39
  const code = ast.toCode('v');
@@ -35,14 +41,14 @@ describe('Atorvastatin Integration Test', () => {
35
41
 
36
42
  let factory;
37
43
  expect(() => {
38
- factory = createFunction('Ring', 'Linear', 'FusedRing', 'Molecule', executableCode);
44
+ factory = createFunction('Ring', 'Linear', 'FusedRing', 'Molecule', 'RawFragment', 'Fragment', executableCode);
39
45
  }).not.toThrow();
40
46
  expect(typeof factory).toBe('function');
41
47
  });
42
48
 
43
49
  test('codegen round-trip: generated code produces valid SMILES', () => {
44
50
  const ast = parse(ATORVASTATIN_SMILES);
45
- const code = ast.toCode('v');
51
+ const code = ast.toCode('v', { verbose: true });
46
52
  const executableCode = stripExports(code);
47
53
 
48
54
  const varMatch = code.match(/export const (v\d+) = /g);
@@ -68,6 +74,12 @@ describe('Simvastatin Integration Test', () => {
68
74
  expect(code).toMatchSnapshot();
69
75
  });
70
76
 
77
+ test('generates valid verbose code via toCode()', () => {
78
+ const ast = parse(SIMVASTATIN_SMILES);
79
+ const code = ast.toCode('v', { verbose: true });
80
+ expect(code).toMatchSnapshot();
81
+ });
82
+
71
83
  test('generated code is valid JavaScript', () => {
72
84
  const ast = parse(SIMVASTATIN_SMILES);
73
85
  const code = ast.toCode('v');
@@ -75,14 +87,14 @@ describe('Simvastatin Integration Test', () => {
75
87
 
76
88
  let factory;
77
89
  expect(() => {
78
- factory = createFunction('Ring', 'Linear', 'FusedRing', 'Molecule', executableCode);
90
+ factory = createFunction('Ring', 'Linear', 'FusedRing', 'Molecule', 'RawFragment', 'Fragment', executableCode);
79
91
  }).not.toThrow();
80
92
  expect(typeof factory).toBe('function');
81
93
  });
82
94
 
83
95
  test('codegen round-trip: generated code produces valid SMILES', () => {
84
96
  const ast = parse(SIMVASTATIN_SMILES);
85
- const code = ast.toCode('v');
97
+ const code = ast.toCode('v', { verbose: true });
86
98
  const executableCode = stripExports(code);
87
99
 
88
100
  const varMatch = code.match(/export const (v\d+) = /g);
@@ -108,6 +120,12 @@ describe('Rosuvastatin Integration Test', () => {
108
120
  expect(code).toMatchSnapshot();
109
121
  });
110
122
 
123
+ test('generates valid verbose code via toCode()', () => {
124
+ const ast = parse(ROSUVASTATIN_SMILES);
125
+ const code = ast.toCode('v', { verbose: true });
126
+ expect(code).toMatchSnapshot();
127
+ });
128
+
111
129
  test('generated code is valid JavaScript', () => {
112
130
  const ast = parse(ROSUVASTATIN_SMILES);
113
131
  const code = ast.toCode('v');
@@ -115,14 +133,14 @@ describe('Rosuvastatin Integration Test', () => {
115
133
 
116
134
  let factory;
117
135
  expect(() => {
118
- factory = createFunction('Ring', 'Linear', 'FusedRing', 'Molecule', executableCode);
136
+ factory = createFunction('Ring', 'Linear', 'FusedRing', 'Molecule', 'RawFragment', 'Fragment', executableCode);
119
137
  }).not.toThrow();
120
138
  expect(typeof factory).toBe('function');
121
139
  });
122
140
 
123
141
  test('codegen round-trip: generated code produces valid SMILES', () => {
124
142
  const ast = parse(ROSUVASTATIN_SMILES);
125
- const code = ast.toCode('v');
143
+ const code = ast.toCode('v', { verbose: true });
126
144
  const executableCode = stripExports(code);
127
145
 
128
146
  const varMatch = code.match(/export const (v\d+) = /g);
@@ -148,6 +166,12 @@ describe('Pravastatin Integration Test', () => {
148
166
  expect(code).toMatchSnapshot();
149
167
  });
150
168
 
169
+ test('generates valid verbose code via toCode()', () => {
170
+ const ast = parse(PRAVASTATIN_SMILES);
171
+ const code = ast.toCode('v', { verbose: true });
172
+ expect(code).toMatchSnapshot();
173
+ });
174
+
151
175
  test('generated code is valid JavaScript', () => {
152
176
  const ast = parse(PRAVASTATIN_SMILES);
153
177
  const code = ast.toCode('v');
@@ -155,14 +179,14 @@ describe('Pravastatin Integration Test', () => {
155
179
 
156
180
  let factory;
157
181
  expect(() => {
158
- factory = createFunction('Ring', 'Linear', 'FusedRing', 'Molecule', executableCode);
182
+ factory = createFunction('Ring', 'Linear', 'FusedRing', 'Molecule', 'RawFragment', 'Fragment', executableCode);
159
183
  }).not.toThrow();
160
184
  expect(typeof factory).toBe('function');
161
185
  });
162
186
 
163
187
  test('codegen round-trip: generated code produces valid SMILES', () => {
164
188
  const ast = parse(PRAVASTATIN_SMILES);
165
- const code = ast.toCode('v');
189
+ const code = ast.toCode('v', { verbose: true });
166
190
  const executableCode = stripExports(code);
167
191
 
168
192
  const varMatch = code.match(/export const (v\d+) = /g);
@@ -188,6 +212,12 @@ describe('Lovastatin Integration Test', () => {
188
212
  expect(code).toMatchSnapshot();
189
213
  });
190
214
 
215
+ test('generates valid verbose code via toCode()', () => {
216
+ const ast = parse(LOVASTATIN_SMILES);
217
+ const code = ast.toCode('v', { verbose: true });
218
+ expect(code).toMatchSnapshot();
219
+ });
220
+
191
221
  test('generated code is valid JavaScript', () => {
192
222
  const ast = parse(LOVASTATIN_SMILES);
193
223
  const code = ast.toCode('v');
@@ -195,14 +225,14 @@ describe('Lovastatin Integration Test', () => {
195
225
 
196
226
  let factory;
197
227
  expect(() => {
198
- factory = createFunction('Ring', 'Linear', 'FusedRing', 'Molecule', executableCode);
228
+ factory = createFunction('Ring', 'Linear', 'FusedRing', 'Molecule', 'RawFragment', 'Fragment', executableCode);
199
229
  }).not.toThrow();
200
230
  expect(typeof factory).toBe('function');
201
231
  });
202
232
 
203
233
  test('codegen round-trip: generated code produces valid SMILES', () => {
204
234
  const ast = parse(LOVASTATIN_SMILES);
205
- const code = ast.toCode('v');
235
+ const code = ast.toCode('v', { verbose: true });
206
236
  const executableCode = stripExports(code);
207
237
 
208
238
  const varMatch = code.match(/export const (v\d+) = /g);
@@ -228,6 +258,12 @@ describe('Fluvastatin Integration Test', () => {
228
258
  expect(code).toMatchSnapshot();
229
259
  });
230
260
 
261
+ test('generates valid verbose code via toCode()', () => {
262
+ const ast = parse(FLUVASTATIN_SMILES);
263
+ const code = ast.toCode('v', { verbose: true });
264
+ expect(code).toMatchSnapshot();
265
+ });
266
+
231
267
  test('generated code is valid JavaScript', () => {
232
268
  const ast = parse(FLUVASTATIN_SMILES);
233
269
  const code = ast.toCode('v');
@@ -235,14 +271,14 @@ describe('Fluvastatin Integration Test', () => {
235
271
 
236
272
  let factory;
237
273
  expect(() => {
238
- factory = createFunction('Ring', 'Linear', 'FusedRing', 'Molecule', executableCode);
274
+ factory = createFunction('Ring', 'Linear', 'FusedRing', 'Molecule', 'RawFragment', 'Fragment', executableCode);
239
275
  }).not.toThrow();
240
276
  expect(typeof factory).toBe('function');
241
277
  });
242
278
 
243
279
  test('codegen round-trip: generated code produces valid SMILES', () => {
244
280
  const ast = parse(FLUVASTATIN_SMILES);
245
- const code = ast.toCode('v');
281
+ const code = ast.toCode('v', { verbose: true });
246
282
  const executableCode = stripExports(code);
247
283
 
248
284
  const varMatch = code.match(/export const (v\d+) = /g);
@@ -268,6 +304,12 @@ describe('Ezetimibe Integration Test', () => {
268
304
  expect(code).toMatchSnapshot();
269
305
  });
270
306
 
307
+ test('generates valid verbose code via toCode()', () => {
308
+ const ast = parse(EZETIMIBE_SMILES);
309
+ const code = ast.toCode('v', { verbose: true });
310
+ expect(code).toMatchSnapshot();
311
+ });
312
+
271
313
  test('generated code is valid JavaScript', () => {
272
314
  const ast = parse(EZETIMIBE_SMILES);
273
315
  const code = ast.toCode('v');
@@ -275,14 +317,14 @@ describe('Ezetimibe Integration Test', () => {
275
317
 
276
318
  let factory;
277
319
  expect(() => {
278
- factory = createFunction('Ring', 'Linear', 'FusedRing', 'Molecule', executableCode);
320
+ factory = createFunction('Ring', 'Linear', 'FusedRing', 'Molecule', 'RawFragment', 'Fragment', executableCode);
279
321
  }).not.toThrow();
280
322
  expect(typeof factory).toBe('function');
281
323
  });
282
324
 
283
325
  test('codegen round-trip: generated code produces valid SMILES', () => {
284
326
  const ast = parse(EZETIMIBE_SMILES);
285
- const code = ast.toCode('v');
327
+ const code = ast.toCode('v', { verbose: true });
286
328
  const executableCode = stripExports(code);
287
329
 
288
330
  const varMatch = code.match(/export const (v\d+) = /g);
@@ -308,6 +350,12 @@ describe('Fenofibrate Integration Test', () => {
308
350
  expect(code).toMatchSnapshot();
309
351
  });
310
352
 
353
+ test('generates valid verbose code via toCode()', () => {
354
+ const ast = parse(FENOFIBRATE_SMILES);
355
+ const code = ast.toCode('v', { verbose: true });
356
+ expect(code).toMatchSnapshot();
357
+ });
358
+
311
359
  test('generated code is valid JavaScript', () => {
312
360
  const ast = parse(FENOFIBRATE_SMILES);
313
361
  const code = ast.toCode('v');
@@ -315,14 +363,14 @@ describe('Fenofibrate Integration Test', () => {
315
363
 
316
364
  let factory;
317
365
  expect(() => {
318
- factory = createFunction('Ring', 'Linear', 'FusedRing', 'Molecule', executableCode);
366
+ factory = createFunction('Ring', 'Linear', 'FusedRing', 'Molecule', 'RawFragment', 'Fragment', executableCode);
319
367
  }).not.toThrow();
320
368
  expect(typeof factory).toBe('function');
321
369
  });
322
370
 
323
371
  test('codegen round-trip: generated code produces valid SMILES', () => {
324
372
  const ast = parse(FENOFIBRATE_SMILES);
325
- const code = ast.toCode('v');
373
+ const code = ast.toCode('v', { verbose: true });
326
374
  const executableCode = stripExports(code);
327
375
 
328
376
  const varMatch = code.match(/export const (v\d+) = /g);
@@ -348,6 +396,12 @@ describe('Gemfibrozil Integration Test', () => {
348
396
  expect(code).toMatchSnapshot();
349
397
  });
350
398
 
399
+ test('generates valid verbose code via toCode()', () => {
400
+ const ast = parse(GEMFIBROZIL_SMILES);
401
+ const code = ast.toCode('v', { verbose: true });
402
+ expect(code).toMatchSnapshot();
403
+ });
404
+
351
405
  test('generated code is valid JavaScript', () => {
352
406
  const ast = parse(GEMFIBROZIL_SMILES);
353
407
  const code = ast.toCode('v');
@@ -355,14 +409,14 @@ describe('Gemfibrozil Integration Test', () => {
355
409
 
356
410
  let factory;
357
411
  expect(() => {
358
- factory = createFunction('Ring', 'Linear', 'FusedRing', 'Molecule', executableCode);
412
+ factory = createFunction('Ring', 'Linear', 'FusedRing', 'Molecule', 'RawFragment', 'Fragment', executableCode);
359
413
  }).not.toThrow();
360
414
  expect(typeof factory).toBe('function');
361
415
  });
362
416
 
363
417
  test('codegen round-trip: generated code produces valid SMILES', () => {
364
418
  const ast = parse(GEMFIBROZIL_SMILES);
365
- const code = ast.toCode('v');
419
+ const code = ast.toCode('v', { verbose: true });
366
420
  const executableCode = stripExports(code);
367
421
 
368
422
  const varMatch = code.match(/export const (v\d+) = /g);
@@ -388,6 +442,12 @@ describe('Pitavastatin Integration Test', () => {
388
442
  expect(code).toMatchSnapshot();
389
443
  });
390
444
 
445
+ test('generates valid verbose code via toCode()', () => {
446
+ const ast = parse(PITAVASTATIN_SMILES);
447
+ const code = ast.toCode('v', { verbose: true });
448
+ expect(code).toMatchSnapshot();
449
+ });
450
+
391
451
  test('generated code is valid JavaScript', () => {
392
452
  const ast = parse(PITAVASTATIN_SMILES);
393
453
  const code = ast.toCode('v');
@@ -395,14 +455,14 @@ describe('Pitavastatin Integration Test', () => {
395
455
 
396
456
  let factory;
397
457
  expect(() => {
398
- factory = createFunction('Ring', 'Linear', 'FusedRing', 'Molecule', executableCode);
458
+ factory = createFunction('Ring', 'Linear', 'FusedRing', 'Molecule', 'RawFragment', 'Fragment', executableCode);
399
459
  }).not.toThrow();
400
460
  expect(typeof factory).toBe('function');
401
461
  });
402
462
 
403
463
  test('codegen round-trip: generated code produces valid SMILES', () => {
404
464
  const ast = parse(PITAVASTATIN_SMILES);
405
- const code = ast.toCode('v');
465
+ const code = ast.toCode('v', { verbose: true });
406
466
  const executableCode = stripExports(code);
407
467
 
408
468
  const varMatch = code.match(/export const (v\d+) = /g);
@@ -428,6 +488,12 @@ describe('Cholesterol Integration Test', () => {
428
488
  expect(code).toMatchSnapshot();
429
489
  });
430
490
 
491
+ test('generates valid verbose code via toCode()', () => {
492
+ const ast = parse(CHOLESTEROL_SMILES);
493
+ const code = ast.toCode('v', { verbose: true });
494
+ expect(code).toMatchSnapshot();
495
+ });
496
+
431
497
  test('generated code is valid JavaScript', () => {
432
498
  const ast = parse(CHOLESTEROL_SMILES);
433
499
  const code = ast.toCode('v');
@@ -435,14 +501,14 @@ describe('Cholesterol Integration Test', () => {
435
501
 
436
502
  let factory;
437
503
  expect(() => {
438
- factory = createFunction('Ring', 'Linear', 'FusedRing', 'Molecule', executableCode);
504
+ factory = createFunction('Ring', 'Linear', 'FusedRing', 'Molecule', 'RawFragment', 'Fragment', executableCode);
439
505
  }).not.toThrow();
440
506
  expect(typeof factory).toBe('function');
441
507
  });
442
508
 
443
509
  test('codegen round-trip: generated code produces valid SMILES', () => {
444
510
  const ast = parse(CHOLESTEROL_SMILES);
445
- const code = ast.toCode('v');
511
+ const code = ast.toCode('v', { verbose: true });
446
512
  const executableCode = stripExports(code);
447
513
 
448
514
  const varMatch = code.match(/export const (v\d+) = /g);
@@ -24,6 +24,12 @@ describe('Dexamethasone Integration Test', () => {
24
24
  expect(code).toMatchSnapshot();
25
25
  });
26
26
 
27
+ test('generates valid verbose code via toCode()', () => {
28
+ const ast = parse(DEXAMETHASONE_SMILES);
29
+ const code = ast.toCode('v', { verbose: true });
30
+ expect(code).toMatchSnapshot();
31
+ });
32
+
27
33
  test('generated code is valid JavaScript', () => {
28
34
  const ast = parse(DEXAMETHASONE_SMILES);
29
35
  const code = ast.toCode('v');
@@ -31,14 +37,14 @@ describe('Dexamethasone Integration Test', () => {
31
37
 
32
38
  let factory;
33
39
  expect(() => {
34
- factory = createFunction('Ring', 'Linear', 'FusedRing', 'Molecule', executableCode);
40
+ factory = createFunction('Ring', 'Linear', 'FusedRing', 'Molecule', 'RawFragment', 'Fragment', executableCode);
35
41
  }).not.toThrow();
36
42
  expect(typeof factory).toBe('function');
37
43
  });
38
44
 
39
45
  test('codegen round-trip: generated code produces valid SMILES', () => {
40
46
  const ast = parse(DEXAMETHASONE_SMILES);
41
- const code = ast.toCode('v');
47
+ const code = ast.toCode('v', { verbose: true });
42
48
  const executableCode = stripExports(code);
43
49
  const varMatch = code.match(/export const (v\d+) = /g);
44
50
  const lastVar = varMatch[varMatch.length - 1].match(/export const (v\d+)/)[1];