diff Resources/CodeGeneration/stonegentool_test.py @ 494:fc17251477d6 bgo-commands-codegen

TS and CPP tests OK. Ongoing code for C++ program that reads list of serialized messages in N files. Requires conan
author bgo-osimis
date Sat, 23 Feb 2019 10:18:13 +0100
parents 6fbf2eae7c88
children 1dbf2d9ed1e4
line wrap: on
line diff
--- a/Resources/CodeGeneration/stonegentool_test.py	Fri Feb 22 10:48:43 2019 +0100
+++ b/Resources/CodeGeneration/stonegentool_test.py	Sat Feb 23 10:18:13 2019 +0100
@@ -6,7 +6,7 @@
 from stonegentool import \
 EatToken,SplitListOfTypes,ParseTemplateType,ProcessSchema, \
 CheckSchemaSchema,LoadSchema,trim,ComputeRequiredDeclarationOrder, \
-GetTemplatingDictFromSchemaFilename,MakeTemplate
+GetTemplatingDictFromSchemaFilename,MakeTemplate,MakeTemplateFromFile
 import unittest
 import os
 import re
@@ -258,7 +258,7 @@
 {% for key in struct['fields']%}    {{key}}:{{CanonToTs(struct['fields'][key])}};
 {% endfor %}
     constructor() {
-{% for key in struct['fields']%}      {{key}} = new {{CanonToTs(struct['fields'][key])}}();
+{% for key in struct['fields']%}      this.{{key}} = new {{CanonToTs(struct['fields'][key])}}();
 {% endfor %}    }
 
     public StoneSerialize(): string {
@@ -375,12 +375,13 @@
     self.assertEqual(renderedCodeRef, renderedCode)
 
   def test_generateWholeTsFile(self):
-    schemaFile = os.path.join(os.path.dirname(__file__), 'test_data', 'test1.yaml')
+    schemaFile = \
+      os.path.join(os.path.dirname(__file__), 'test_data', 'test1.yaml')
     tdico = GetTemplatingDictFromSchemaFilename(schemaFile)
-    tsTemplateFile = os.path.join(os.path.dirname(__file__), 'test_data', 'test1.yaml')
+    tsTemplateFile = \
+      os.path.join(os.path.dirname(__file__), 'template.in.ts')
     template = MakeTemplateFromFile(tsTemplateFile)
     renderedCode = template.render(**tdico)
-
     print(renderedCode)
 
   def test_GenerateTypeScriptHandlerInterface(self):