harmonyc 0.8.1 → 0.8.2

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.
@@ -99,13 +99,13 @@ export class NodeTest {
99
99
  }
100
100
  }
101
101
  phrase(p) {
102
- const phrasefn = this.functionName(p);
102
+ const phrasefn = functionName(p);
103
103
  if (!this.phraseFns.has(phrasefn))
104
104
  this.phraseFns.set(phrasefn, p);
105
105
  const f = this.featureVars.get(p.feature.name);
106
106
  const args = p.args.map((a) => a.toCode(this));
107
107
  args.push(...this.extraArgs);
108
- this.tf.print(`await ${f}.${this.functionName(p)}(${args.join(', ')});`);
108
+ this.tf.print(`await ${f}.${functionName(p)}(${args.join(', ')});`);
109
109
  }
110
110
  stringLiteral(text) {
111
111
  return str(text);
@@ -122,14 +122,6 @@ export class NodeTest {
122
122
  variantParamDeclaration(index) {
123
123
  return `${this.paramName(index)}: any`;
124
124
  }
125
- functionName(phrase) {
126
- const { kind } = phrase;
127
- return ((kind === 'response' ? 'Then_' : 'When_') +
128
- ([...phrase.content, phrase.docstring ? [phrase.docstring] : []]
129
- .map((c) => c instanceof Word ? underscore(c.text) : c instanceof Arg ? '_' : '')
130
- .filter((x) => x)
131
- .join('_') || '_'));
132
- }
133
125
  }
134
126
  function str(s) {
135
127
  if (s.includes('\n'))
@@ -171,3 +163,11 @@ function abbrev(s) {
171
163
  .map((x) => x.charAt(0).toUpperCase())
172
164
  .join('');
173
165
  }
166
+ export function functionName(phrase) {
167
+ const { kind } = phrase;
168
+ return ((kind === 'response' ? 'Then_' : 'When_') +
169
+ ([...phrase.content, phrase.docstring ? [phrase.docstring] : []]
170
+ .flatMap((c) => c instanceof Word ? words(c.text) : c instanceof Arg ? ['_'] : [])
171
+ .filter((x) => x)
172
+ .join('_') || '_'));
173
+ }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "harmonyc",
3
3
  "description": "Harmony Code - model-driven BDD for Vitest",
4
- "version": "0.8.1",
4
+ "version": "0.8.2",
5
5
  "author": "Bernát Kalló",
6
6
  "type": "module",
7
7
  "bin": {
@@ -1,9 +0,0 @@
1
- export default class LexerSteps {
2
- async When__(x) {
3
- throw new Error("Pending: When__");
4
- }
5
- async Then__(x) {
6
- throw new Error("Pending: Then__");
7
- }
8
- }
9
- ;
@@ -1,12 +0,0 @@
1
- export default class ParserSteps {
2
- async When_production__(x) {
3
- throw new Error("Pending: When_production__");
4
- }
5
- async When__(x) {
6
- throw new Error("Pending: When__");
7
- }
8
- async Then__(x) {
9
- throw new Error("Pending: Then__");
10
- }
11
- }
12
- ;