theprogrammablemind_4wp 7.5.7-beta.9 → 7.5.8-beta.0

Sign up to get free protection for your applications and to get access to all the features.
package/client.js CHANGED
@@ -58,10 +58,10 @@ const vimdiff = (actualJSON, expectedJSON) => {
58
58
  // console.log(`vimdiff ${path}/actual.json ${path}/expected.json`)
59
59
  {
60
60
  const editor = runtime.process.env.EDITOR || 'vimdiff'
61
- const child = runtime.child_process.spawn(editor, [`${path}/expected.json`, `${path}/actual.json`], { stdio: 'inherit' })
62
- child.on('exit', function (e, code) {
63
- console.log('finished')
64
- })
61
+ debugger
62
+ // const child = runtime.child_process.spawn(editor, [`${path}/expected.json`, `${path}/actual.json`], { stdio: 'inherit' })
63
+ console.log(`${editor} ${path}/expected.json ${path}/actual.json`)
64
+ runtime.child_process.execSync(`${editor} ${path}/expected.json ${path}/actual.json`, {stdio: 'inherit'})
65
65
  }
66
66
  }
67
67
 
@@ -100,10 +100,20 @@ const asList = (context) => {
100
100
  }
101
101
  }
102
102
 
103
+ class ErrorReason extends Error {
104
+ constructor(context) {
105
+ super(JSON.stringify(context))
106
+ this.reason = context
107
+ }
108
+ }
109
+
103
110
  const setupArgs = (args, config, logs, hierarchy) => {
104
111
  config.setArgs(args)
105
- args.calls = new InitCalls()
112
+ args.calls = new InitCalls(config.name)
106
113
  args.km = (name) => config.getConfig(name)
114
+ args.error = (context) => {
115
+ throw new ErrorReason(context)
116
+ }
107
117
  args.kms = config.getConfigs()
108
118
  args.config = config
109
119
  args.hierarchy = hierarchy
@@ -395,7 +405,8 @@ const processContextsB = ({ config, hierarchy, semantics, generators, json, isTe
395
405
  const mostCalled = semantics.getMostCalled()
396
406
  e.message += `\nThe most called semantic was:\nnotes: ${mostCalled.notes}\nmatch: ${mostCalled.matcher.toString()}\napply: ${mostCalled._apply.toString()}\n`
397
407
  }
398
- throw e;
408
+ // contextPrime = semantics.apply(args, { marker: 'error', context, error: e })
409
+ contextPrime = semantics.apply(args, { marker: 'error', context, reason: e.reason })
399
410
  }
400
411
  }
401
412
  }
@@ -1578,7 +1589,7 @@ const knowledgeModule = async ({
1578
1589
  runTests(config, test, { debug: args.debug, testConfig: useTestConfig, verbose: args.testVerbose || args.testAllVerbose, stopAtFirstError: !args.testAllVerbose }).then((results) => {
1579
1590
  if (results.length > 0 && args.vimdiff) {
1580
1591
  for (const result of results) {
1581
- vimdiff(result.expected, result.actual)
1592
+ vimdiff(result.actual, result.expected)
1582
1593
  }
1583
1594
  }
1584
1595
  let newError = false
@@ -1632,6 +1643,9 @@ const knowledgeModule = async ({
1632
1643
  lines.setElement(1, 1, 'actual checked')
1633
1644
  lines.setElement(2, 2, JSON.stringify(result.actual.checked, null, 2))
1634
1645
  lines.log()
1646
+ if (args.vimdiff) {
1647
+ vimdiff(result.actual.checked, result.expected.checked)
1648
+ }
1635
1649
  newError = true
1636
1650
  headerShown = true
1637
1651
  }
package/package.json CHANGED
@@ -63,6 +63,6 @@
63
63
  "json-stable-stringify": "^1.0.1",
64
64
  "node-fetch": "^2.6.1"
65
65
  },
66
- "version": "7.5.7-beta.9",
66
+ "version": "7.5.8-beta.0",
67
67
  "license": "ISC"
68
68
  }
package/src/helpers.js CHANGED
@@ -172,10 +172,11 @@ nextContextId = 0
172
172
 
173
173
  class InitCalls {
174
174
 
175
- constructor() {
175
+ constructor(name) {
176
176
  this.nextCallId = 0
177
177
  this.nextContextId = 0
178
178
  this.stack = []
179
+ this.name = name
179
180
  }
180
181
 
181
182
  start() {
@@ -192,13 +193,13 @@ class InitCalls {
192
193
  // this.nextCallId += 1
193
194
  // this.stack.push(this.nextCallId)
194
195
  this.stack.push(this.nextCallId)
195
- const calls = this.stack.map( (call) => `call${call}` )
196
+ const calls = this.stack.map( (call) => `${this.name}#call${call}` )
196
197
  // return `Context#${this.nextContextId}: ${calls}`
197
198
  return `Context#${nextContextId}: ${calls}`
198
199
  }
199
200
 
200
201
  current() {
201
- return `call${this.stack[this.stack.length-1]}`
202
+ return `${this.name}#call${this.stack[this.stack.length-1]}`
202
203
  }
203
204
 
204
205
  touch(context) {
package/src/semantics.js CHANGED
@@ -237,7 +237,7 @@ class Semantics {
237
237
  // this.logs.push(message)
238
238
  // return [message]
239
239
  args.calls.pop()
240
- throw { error: [message], logs: this.logs }
240
+ throw { error: [message], logs: this.logs, reason: e.reason }
241
241
  }
242
242
  args.calls.touch(contextPrime)
243
243
  // this.logs.push(`Semantics: applied ${semantic.toString()}\n to\n ${JSON.stringify(context)}\n the result was ${JSON.stringify(contextPrime)}\n`)