theprogrammablemind_4wp 7.5.0-beta.14 → 7.5.0-beta.16

Sign up to get free protection for your applications and to get access to all the features.
package/client.js CHANGED
@@ -78,7 +78,15 @@ const listable = (hierarchy) => (c, type) => {
78
78
  return false
79
79
  }
80
80
 
81
- const isA = (hierarchy) => (child, parent) => hierarchy.isA(child, parent)
81
+ const isA = (hierarchy) => (child, parent) => {
82
+ if (child.marker) {
83
+ child = child.marker
84
+ }
85
+ if (parent.marker) {
86
+ parent = parent.marker
87
+ }
88
+ return hierarchy.isA(child, parent)
89
+ }
82
90
 
83
91
  const asList = (context) => {
84
92
  if (context.marker === 'list') {
@@ -670,9 +678,12 @@ const runTest = async (config, expected, { verbose, afterTest, testConfig, debug
670
678
  defaultErrorHandler(error)
671
679
  }
672
680
 
673
- const objects = getObjects(config.config.objects)(config.uuid)
681
+ let objects = getObjects(config.config.objects)(config.uuid)
682
+ if (testConfig.testModuleName) {
683
+ objects = getObjects(config.config.objects)(config.getConfigs()[testConfig.testModuleName].uuid)
684
+ }
674
685
  config.beforeQuery({ query: test, isModule: false, objects })
675
- config.resetMotivations()
686
+ // config.resetMotivations()
676
687
  try {
677
688
  const result = await _process(config, test, { errorHandler, isTest: true })
678
689
  result.query = test
@@ -783,7 +794,7 @@ const runTests = async (config, testFile, juicyBits) => {
783
794
  const saveTest = async (testFile, config, test, expected, testConfig, saveDeveloper) => {
784
795
  config.rebuild()
785
796
  const objects = getObjects(config.config.objects)(config.uuid)
786
- config.resetMotivations()
797
+ //config.resetMotivations()
787
798
  config.beforeQuery({ query: test, isModule: false, objects })
788
799
  console.log(test)
789
800
  const result = await _process(config, test, { isTest: true })
@@ -1252,7 +1263,7 @@ const knowledgeModule = async ({
1252
1263
  description: 'Entodicton knowledge module'
1253
1264
  })
1254
1265
 
1255
- parser.add_argument('-tfn', '--testFileName', { help: 'Override the test file for the module when the tests are being run' })
1266
+ parser.add_argument('-tmn', '--testModuleName', { help: 'When running tests instead of using the current modules tests use the specified modules tests' })
1256
1267
  parser.add_argument('-t', '--test', { action: 'store_true', help: 'Run the tests. Create tests by running with the --query + --save flag' })
1257
1268
  parser.add_argument('-tv', '--testVerbose', { action: 'store_true', help: 'Run the tests in verbose mode. Create tests by running with the --query or --loop with the --save flag' })
1258
1269
  parser.add_argument('-tva', '--testAllVerbose', { action: 'store_true', help: 'Run the tests in verbose mode. All the tests will be run instead of stopping at first failure. Create tests by running with the --query or --loop with the --save flag' })
@@ -1466,7 +1477,15 @@ const knowledgeModule = async ({
1466
1477
  }
1467
1478
  return
1468
1479
  }
1469
- runTests(config, args.testFileName ? `${args.testFileName}.test.json` : test, { debug: args.debug, testConfig: testConfig, verbose: args.testVerbose || args.testAllVerbose, stopAtFirstError: !args.testAllVerbose }).then((results) => {
1480
+ let useTestConfig = testConfig
1481
+ if (args.testModuleName) {
1482
+ useTestConfig = config.getConfigs()[args.testModuleName].getTestConfig()
1483
+ useTestConfig.testModuleName = args.testModuleName
1484
+ test = useTestConfig.name
1485
+
1486
+ }
1487
+ // runTests(config, args.testFileName ? `${args.testFileName}.test.json` : test, { debug: args.debug, testConfig: testConfig, verbose: args.testVerbose || args.testAllVerbose, stopAtFirstError: !args.testAllVerbose }).then((results) => {
1488
+ runTests(config, test, { debug: args.debug, testConfig: useTestConfig, verbose: args.testVerbose || args.testAllVerbose, stopAtFirstError: !args.testAllVerbose }).then((results) => {
1470
1489
  if (results.length > 0 && args.vimdiff) {
1471
1490
  for (const result of results) {
1472
1491
  vimdiff(result.expected, result.actual)
@@ -1515,19 +1534,25 @@ const knowledgeModule = async ({
1515
1534
  if (!headerShown) {
1516
1535
  console.log(' Failure')
1517
1536
  }
1518
- console.log(' expected checked', result.expected.checked)
1519
- console.log(' actual checked ', result.actual.checked)
1537
+ const widths = [4, 18, 72]
1538
+ const lines = new Lines(widths)
1539
+ lines.setElement(1, 1, 'expected checked')
1540
+ lines.setElement(2, 2, JSON.stringify(result.expected.checked, null, 2))
1541
+ lines.log()
1542
+ lines.setElement(1, 1, 'actual checked')
1543
+ lines.setElement(2, 2, JSON.stringify(result.actual.checked, null, 2))
1544
+ lines.log()
1520
1545
  newError = true
1521
1546
  headerShown = true
1522
1547
  }
1523
1548
  }
1524
1549
  }
1525
1550
  if (!headerShown) {
1526
- if (!(testConfig.check && testConfig.check.length > 0)) {
1551
+ if (!(useTestConfig.check && useTestConfig.check.length > 0)) {
1527
1552
  console.log('There are failures due to things other than paraphrases, responses and checked properties being different. They are not shown because you ran -tv or -tva which only shows difference in paraphrase and results. Usually what I do is -s and do a diff to make sure there are no other problems. If the paraphrases or results were different they would have shown here.')
1528
1553
  }
1529
1554
  }
1530
- if (!(testConfig.check && testConfig.check.length > 0)) {
1555
+ if (!(useTestConfig.check && useTestConfig.check.length > 0)) {
1531
1556
  console.log('use -v arg to write files expected.json and actual.json in the current directory for detailed comparison. Or do -s and then git diff the changes.')
1532
1557
  // console.log(JSON.stringify(contexts))
1533
1558
  console.log('**************************** ERRORS ************************')
@@ -1589,6 +1614,7 @@ const knowledgeModule = async ({
1589
1614
  }
1590
1615
  } else {
1591
1616
  config.addAssociationsFromTests(config.tests);
1617
+ config.setTestConfig(testConfig)
1592
1618
  //for (let query in config.tests) {
1593
1619
  // config.addAssociations(config.tests[query].associations || []);
1594
1620
  //}
package/lines.js CHANGED
@@ -12,6 +12,9 @@ class Lines {
12
12
  // will wrap to next line within the column
13
13
  setElement (row, column, value) {
14
14
  const values = value.toString().split('\n')
15
+ if (column >= this.widths.length) {
16
+ throw "Column out of range."
17
+ }
15
18
  const width = this.widths[column]
16
19
  let index = 0
17
20
  for (value of values) {
package/package.json CHANGED
@@ -61,6 +61,6 @@
61
61
  "json-stable-stringify": "^1.0.1",
62
62
  "node-fetch": "^2.6.1"
63
63
  },
64
- "version": "7.5.0-beta.14",
64
+ "version": "7.5.0-beta.16",
65
65
  "license": "ISC"
66
66
  }
package/src/config.js CHANGED
@@ -330,6 +330,17 @@ class Config {
330
330
  return `${maybeName}${counter}`
331
331
  }
332
332
 
333
+ setTestConfig(testConfig) {
334
+ if (this.name == 'ui') {
335
+ console.log('ui setting testConfig')
336
+ }
337
+ this.testConfig = testConfig
338
+ }
339
+
340
+ getTestConfig() {
341
+ return this.testConfig
342
+ }
343
+
333
344
  defaultConfig () {
334
345
  this.config = {
335
346
  operators: [], // TODO
@@ -1379,12 +1390,13 @@ class Config {
1379
1390
  cp.name = this.name
1380
1391
  cp.description = this.description
1381
1392
  cp.tests = this.tests
1382
- cp.motivations = this.motivations
1393
+ cp.motivations = [...this.motivations]
1383
1394
  cp.isModule = this.isModule
1384
1395
  cp.loadedForTesting = this.loadedForTesting
1385
1396
  cp.initInstances = this.initInstances.slice()
1386
1397
  cp.instances = this.instances.slice()
1387
1398
  cp.configCounter = this.configCounter
1399
+ cp.testConfig = this.testConfig
1388
1400
 
1389
1401
  cp.initConfig = _.cloneDeep(this.initConfig)
1390
1402
  cp.defaultConfig()
@@ -1747,6 +1759,7 @@ class Config {
1747
1759
  }
1748
1760
  this.config.objects.namespaced = {}
1749
1761
  this.resetWasInitialized()
1762
+ this.resetMotivations()
1750
1763
 
1751
1764
  // reorder configs base on load ordering
1752
1765
  {