Demonstrate and use numeric literals in calc args

This commit is contained in:
Andrew Johnson
2017-04-29 20:43:54 -05:00
parent f65b2119ad
commit 1cad1c5ba6
3 changed files with 9 additions and 5 deletions

View File

@@ -92,7 +92,7 @@ from <tt>const</tt> links.</li>
<pre>
field(INP, {calc:{expr:"A+B+1",
args:[{const:5}, # A
args:[5, # A
{const:6}] # B
}})
</pre>

View File

@@ -19,7 +19,7 @@ record(stringout, "rec:link2") {
record(ai, "rec:j1") {
field(INP, {calc:{
expr:"A+5",
args:{const:5}
args:5
}})
field(PINI, "YES")
}

View File

@@ -73,10 +73,14 @@ static void testRetargetJLink(void)
testDiag("In testRetargetJLink");
testdbGetFieldEqual("rec:j1", DBF_DOUBLE, 10.0);
/* without [] */
testLongStrEq("rec:j1.INP$", "{\"calc\":{\"expr\":\"A+5\",\"args\":{\"const\":5}}}");
/* minimal args */
testLongStrEq("rec:j1.INP$", "{\"calc\":{\"expr\":\"A+5\",\"args\":5}}");
/* with [] */
testPutLongStr("rec:j1.INP$", "{\"calc\":{\"expr\":\"A+5\",\"args\":[7]}}");
testdbPutFieldOk("rec:j1.PROC", DBF_LONG, 1);
/* with const */
testPutLongStr("rec:j1.INP$", "{\"calc\":{\"expr\":\"A+5\",\"args\":[{\"const\":7}]}}");
testdbPutFieldOk("rec:j1.PROC", DBF_LONG, 1);
@@ -86,7 +90,7 @@ static void testRetargetJLink(void)
MAIN(linkRetargetLinkTest)
{
testPlan(16);
testPlan(18);
testdbPrepare();