Skip to content
This repository has been archived by the owner on Sep 7, 2023. It is now read-only.

Commit

Permalink
fix(formula) Do not quote formula results of type string
Browse files Browse the repository at this point in the history
Signed-off-by: Jerome Simeon <[email protected]>
  • Loading branch information
jeromesimeon committed Aug 25, 2020
1 parent 47fd012 commit 348da06
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 41 deletions.
2 changes: 1 addition & 1 deletion backends/javascript/ergo-runtime.js
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ function toString(v) {
return toStringQ(v, "\"");
}
function generateText(v) {
return toTextQ(v, "\"");
return toTextQ(v, "");
}
function isEnum(v) {
if (v.type) {
Expand Down
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/ergo-cli/extracted/ergoccore.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion packages/ergo-cli/extracted/ergotopcore.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/ergo-compiler/extracted/compilercore.js

Large diffs are not rendered by default.

46 changes: 23 additions & 23 deletions packages/ergo-compiler/test/logicmanager.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,9 @@ describe('LogicManager', () => {
logicManager.compileLogicSync(false);
logicManager.getInvokeCall('helloworld').length.should.equal(250);
logicManager.getDispatchCall().length.should.equal(172);
logicManager.getScriptManager().getCompiledScript().getContents().length.should.equal(33556);
logicManager.getScriptManager().getCompiledScript().getContents().length.should.equal(33554);
logicManager.compileLogicSync(false);
logicManager.getScriptManager().getCompiledScript().getContents().length.should.equal(33556);
logicManager.getScriptManager().getCompiledScript().getContents().length.should.equal(33554);
});

it('should succeed creating a dispatch call for a JS logic file with a contract class (ES6)', () => {
Expand Down Expand Up @@ -194,9 +194,9 @@ describe('LogicManager', () => {
logicManager.compileLogic(false).then((logicCode) => {
logicManager.getInvokeCall('helloworld').length.should.equal(250);
logicManager.getDispatchCall().length.should.equal(172);
logicManager.getScriptManager().getCompiledScript().getContents().length.should.equal(33556);
logicManager.getScriptManager().getCompiledScript().getContents().length.should.equal(33554);
logicManager.compileLogicSync(false);
logicManager.getScriptManager().getCompiledScript().getContents().length.should.equal(33556);
logicManager.getScriptManager().getCompiledScript().getContents().length.should.equal(33554);
});
});

Expand All @@ -213,16 +213,16 @@ describe('LogicManager', () => {
logicManager.compileLogicSync(false);
logicManager.getInvokeCall('helloworld').length.should.equal(250);
logicManager.getDispatchCall().length.should.equal(172);
logicManager.getScriptManager().getCompiledScript().getContents().length.should.equal(33556);
logicManager.getScriptManager().getCompiledScript().getContents().length.should.equal(33554);
logicManager.compileLogicSync(false);
logicManager.getScriptManager().getCompiledScript().getContents().length.should.equal(33556);
logicManager.getScriptManager().getCompiledScript().getContents().length.should.equal(33554);
});

it('should load a logic file (without extension) to the script manager', () => {
const logicManager = new LogicManager('cicero');
logicManager.addLogicFile(ergoSample,'test');
logicManager.compileLogicSync(false);
logicManager.getScriptManager().getCompiledScript().getContents().length.should.equal(33556);
logicManager.getScriptManager().getCompiledScript().getContents().length.should.equal(33554);
});

it('should set the contract name', () => {
Expand All @@ -238,15 +238,15 @@ describe('LogicManager', () => {
logicManager.addLogicFile(ergoSample,'test.ergo');
logicManager.getTarget().should.equal('cicero');
logicManager.compileLogicSync(false);
logicManager.getScriptManager().getCompiledScript().getContents().length.should.equal(33556);
logicManager.getScriptManager().getCompiledScript().getContents().length.should.equal(33554);
logicManager.setTarget('es6', true);
logicManager.getTarget().should.equal('es6');
const contractName = 'org.accordproject.helloemit.HelloWorld';
logicManager.setContractName(contractName);
logicManager.getContractName().should.equal(ErgoCompiler.contractCallName(contractName));
logicManager.getInvokeCall('helloworld').length.should.equal(250);
logicManager.getDispatchCall().length.should.equal(234);
logicManager.getScriptManager().getCompiledScript().getContents().length.should.equal(31861);
logicManager.getScriptManager().getCompiledScript().getContents().length.should.equal(31859);
});

it('should fail to create init and dispatch for ES6 without a contract name', () => {
Expand All @@ -256,29 +256,29 @@ describe('LogicManager', () => {
logicManager.compileLogicSync(false);
logicManager.getInvokeCall('helloworld').length.should.equal(250);
logicManager.getDispatchCall().length.should.equal(234);
logicManager.getScriptManager().getCompiledScript().getContents().length.should.equal(31861);
logicManager.getScriptManager().getCompiledScript().getContents().length.should.equal(31859);
});

it('should set the compilation target to ES6 but not recompile the logic', () => {
const logicManager = new LogicManager('cicero');
logicManager.addLogicFile(ergoSample,'test.ergo');
logicManager.compileLogicSync(false);
logicManager.getScriptManager().getCompiledScript().getContents().length.should.equal(33556);
logicManager.getScriptManager().getCompiledScript().getContents().length.should.equal(33554);
logicManager.setTarget('es6', false);
logicManager.getScriptManager().getCompiledScript().getContents().length.should.equal(33556);
logicManager.getScriptManager().getCompiledScript().getContents().length.should.equal(33554);
});

it('should set the compilation target to ES5', () => {
const logicManager = new LogicManager('cicero');
logicManager.addLogicFile(ergoSample,'test.ergo');
logicManager.getTarget().should.equal('cicero');
logicManager.compileLogicSync(false);
logicManager.getScriptManager().getCompiledScript().getContents().length.should.equal(33556);
logicManager.getScriptManager().getCompiledScript().getContents().length.should.equal(33554);
logicManager.setTarget('es5', true);
logicManager.getTarget().should.equal('es5');
logicManager.getInvokeCall('helloworld').length.should.equal(174);
logicManager.getDispatchCall().length.should.equal(158);
logicManager.getScriptManager().getCompiledScript().getContents().length.should.equal(31715);
logicManager.getScriptManager().getCompiledScript().getContents().length.should.equal(31713);
});

it('should fail to create init code for Java', () => {
Expand Down Expand Up @@ -312,7 +312,7 @@ describe('LogicManager', () => {
'model.cto'
]);
modelManager.getModels()[0].content.length.should.equal(1330);
logicManager.getScriptManager().getCompiledScript().getContents().length.should.equal(41118);
logicManager.getScriptManager().getCompiledScript().getContents().length.should.equal(41116);
});

it('should load a directory with formula', async function () {
Expand All @@ -326,7 +326,7 @@ describe('LogicManager', () => {
'model.cto'
]);
modelManager.getModels()[0].content.length.should.equal(1330);
logicManager.getScriptManager().getCompiledScript().getContents().length.should.equal(36076);
logicManager.getScriptManager().getCompiledScript().getContents().length.should.equal(36074);
});
});

Expand All @@ -343,7 +343,7 @@ describe('LogicManager', () => {
'model.cto'
]);
modelManager.getModels()[0].content.length.should.equal(1330);
logicManager.getScriptManager().getCompiledScript().getContents().length.should.equal(41118);
logicManager.getScriptManager().getCompiledScript().getContents().length.should.equal(41116);
});

it('should load a Zip with formula', async function () {
Expand All @@ -358,7 +358,7 @@ describe('LogicManager', () => {
'model.cto'
]);
modelManager.getModels()[0].content.length.should.equal(1330);
logicManager.getScriptManager().getCompiledScript().getContents().length.should.equal(36076);
logicManager.getScriptManager().getCompiledScript().getContents().length.should.equal(36074);
});
});

Expand All @@ -379,7 +379,7 @@ describe('LogicManager', () => {
'model.cto'
]);
modelManager.getModels()[0].content.length.should.equal(1330);
logicManager.getScriptManager().getCompiledScript().getContents().length.should.equal(41118);
logicManager.getScriptManager().getCompiledScript().getContents().length.should.equal(41116);
});

it('should load a Zip with formula', async function () {
Expand All @@ -398,7 +398,7 @@ describe('LogicManager', () => {
'model.cto'
]);
modelManager.getModels()[0].content.length.should.equal(1330);
logicManager.getScriptManager().getCompiledScript().getContents().length.should.equal(36076);
logicManager.getScriptManager().getCompiledScript().getContents().length.should.equal(36074);
});
});

Expand Down Expand Up @@ -436,15 +436,15 @@ describe('LogicManager', () => {
logicManager.compileLogicSync(false);
logicManager.getInvokeCall('helloworld').length.should.equal(250);
logicManager.getDispatchCall().length.should.equal(172);
logicManager.getScriptManager().getCompiledScript().getContents().length.should.equal(33556);
logicManager.getScriptManager().getCompiledScript().getContents().length.should.equal(33554);
logicManager.updateLogic(ergoSample,'test.ergo');
logicManager.compileLogicSync(false);
logicManager.updateLogic(ergoSample,'testNEW.ergo');
logicManager.compileLogicSync(false);
logicManager.getScriptManager().getCompiledScript().getContents().length.should.equal(33556);
logicManager.getScriptManager().getCompiledScript().getContents().length.should.equal(33554);
logicManager.updateLogic(ergoSample3,'test.ergo');
logicManager.compileLogicSync(false);
logicManager.getScriptManager().getCompiledScript().getContents().length.should.equal(33556);
logicManager.getScriptManager().getCompiledScript().getContents().length.should.equal(33554);
});

});
Expand Down
12 changes: 6 additions & 6 deletions packages/ergo-compiler/test/scriptmanager.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ describe('ScriptManager', () => {
scriptManager.getLogic().map(x => x.name).should.deep.equal(['test.ergo']);
scriptManager.allFunctionDeclarations().length.should.equal(2);
scriptManager.allFunctionDeclarations().map(x => x.getName()).should.deep.equal(['paymentClause','__dispatch']);
scriptManager.getCompiledScript().getContents().length.should.equal(33556);
scriptManager.getCompiledJavaScript().length.should.equal(33556);
scriptManager.getCompiledScript().getContents().length.should.equal(33554);
scriptManager.getCompiledJavaScript().length.should.equal(33554);
scriptManager.allFunctionDeclarations().length.should.equal(114);
scriptManager.allFunctionDeclarations().filter(x => x.name === '__init').length.should.equal(1);
expect(scriptManager.hasInit()).to.not.throw;
Expand All @@ -76,8 +76,8 @@ describe('ScriptManager', () => {
const script2 = scriptManager.createScript('test.ergo','.ergo',ergoSample);
scriptManager.addScript(script1);
scriptManager.addScript(script2);
scriptManager.compileLogic().getContents().length.should.equal(33556);
scriptManager.getCompiledScript().getContents().length.should.equal(33556);
scriptManager.compileLogic().getContents().length.should.equal(33554);
scriptManager.getCompiledScript().getContents().length.should.equal(33554);
scriptManager.getAllScripts().length.should.equal(3);
});

Expand Down Expand Up @@ -182,8 +182,8 @@ describe('ScriptManager', () => {
const script2 = scriptManager.createScript('test.ergo','.ergo',ergoSample);
scriptManager.addScript(script1);
scriptManager.addScript(script2);
scriptManager.compileLogic().getContents().length.should.equal(33556);
scriptManager.getCompiledJavaScript().length.should.equal(33556);
scriptManager.compileLogic().getContents().length.should.equal(33554);
scriptManager.getCompiledJavaScript().length.should.equal(33554);
scriptManager.clearScripts();
return (() => scriptManager.getCompiledJavaScript()).should.throw('Did not find any compiled JavaScript logic');
});
Expand Down
2 changes: 1 addition & 1 deletion packages/ergo-engine/test/workload.json
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@
"calculate": "interests",
"currentTime": "2019-01-01T16:34:00-05:00",
"expected": {
"response": "\"£2,886.0 (GBP)\""
"response": "£2,886.0 (GBP)"
}
},
{
Expand Down

0 comments on commit 348da06

Please sign in to comment.