diff --git a/src/interpreter/index.ts b/src/interpreter/index.ts index 31b6af75..db85946d 100644 --- a/src/interpreter/index.ts +++ b/src/interpreter/index.ts @@ -44,6 +44,7 @@ import pSettle from "p-settle"; import { CoverageCollector } from "../coverage"; import { ManifestValue } from "../preprocessor/Manifest"; import { generateArgumentMismatchError } from "./ArgumentMismatch"; +import Long from "long"; /** The set of options used to configure an interpreter's execution. */ export interface ExecutionOptions { @@ -422,7 +423,9 @@ export class Interpreter implements Expr.Visitor, Stmt.Visitor ); } } else { - this.stdout.write(this.evaluate(printable).toString()); + const toPrint = this.evaluate(printable); + const str = isBrsNumber(toPrint) && this.isPositive(toPrint.getValue()) ? " " : ""; + this.stdout.write(str + toPrint.toString()); } }); @@ -575,8 +578,8 @@ export class Interpreter implements Expr.Visitor, Stmt.Visitor if ( isBrsNumber(left) && isBrsNumber(right) && - right.getValue() >= 0 && - right.getValue() < 32 + this.isPositive(right.getValue()) && + this.lessThan(right.getValue(), 32) ) { return left.leftShift(right); } else if (isBrsNumber(left) && isBrsNumber(right)) { @@ -614,8 +617,8 @@ export class Interpreter implements Expr.Visitor, Stmt.Visitor if ( isBrsNumber(left) && isBrsNumber(right) && - right.getValue() >= 0 && - right.getValue() < 32 + this.isPositive(right.getValue()) && + this.lessThan(right.getValue(), 32) ) { return left.rightShift(right); } else if (isBrsNumber(left) && isBrsNumber(right)) { @@ -1673,4 +1676,18 @@ export class Interpreter implements Expr.Visitor, Stmt.Visitor this.events.emit("err", err); throw err; } + + private isPositive(value: number | Long): boolean { + if (value instanceof Long) { + return value.isPositive(); + } + return value >= 0; + } + + private lessThan(value: number | Long, compare: number): boolean { + if (value instanceof Long) { + return value.lessThan(compare); + } + return value < compare; + } } diff --git a/test/e2e/BrsComponents.test.js b/test/e2e/BrsComponents.test.js index 9d8e40e1..dc8574ad 100644 --- a/test/e2e/BrsComponents.test.js +++ b/test/e2e/BrsComponents.test.js @@ -33,7 +33,7 @@ describe("end to end brightscript functions", () => { expect(allArgs(outputStreams.stdout.write).filter((arg) => arg !== "\n")).toEqual([ "array length: ", - "4", + " 4", "last element: ", "sit", "first element: ", @@ -50,11 +50,11 @@ describe("end to end brightscript functions", () => { expect(allArgs(outputStreams.stdout.write).filter((arg) => arg !== "\n")).toEqual([ "AA size: ", - "3", + " 3", "AA keys size: ", - "3", + " 3", "AA items size: ", - "3", + " 3", "can delete elements: ", "true", "can look up elements: ", @@ -68,7 +68,7 @@ describe("end to end brightscript functions", () => { "items() example key: ", "bar", "items() example value: ", - "5", + " 5", "key is not found if sensitive mode is enabled", "false", "key exits with correct casing", @@ -86,7 +86,7 @@ describe("end to end brightscript functions", () => { "saved key after accessing by index: ", "Dd", "AA keys size: ", - "1", + " 1", ]); }); @@ -165,23 +165,23 @@ describe("end to end brightscript functions", () => { "Weekday: ", "Friday", "Day of Week: ", - "5", + " 5", "Day of Month: ", - "12", + " 12", "Month: ", - "11", + " 11", "Year: ", - "2010", + " 2010", "Hours: ", - "13", + " 13", "Minutes: ", - "14", + " 14", "Seconds: ", - "15", + " 15", "Last Day of Month: ", - "30", + " 30", "Milliseconds: ", - "160", + " 160", "ISO String UTC: ", "2010-11-12T13:14:15Z", ]); @@ -192,23 +192,23 @@ describe("end to end brightscript functions", () => { expect(allArgs(outputStreams.stdout.write).filter((arg) => arg !== "\n")).toEqual([ "can return seconds from date until now: ", - "373447701", + " 373447701", "can return seconds from date until now: ", - "373447701", + " 373447701", "can return seconds from date until now: ", - "373447649", + " 373447649", "can return seconds from date until now: ", - "373444829", + " 373444829", "can return seconds from date until now: ", - "373426829", + " 373426829", "can return seconds from date until now: ", - "373426829", + " 373426829", "can return seconds from date until now: ", - "372649229", + " 372649229", "can return seconds from date until now: ", - "346383629", + " 346383629", "can return 2077252342 for date that can't be parsed: ", - "2077252342", + " 2077252342", ]); }); @@ -270,7 +270,7 @@ describe("end to end brightscript functions", () => { "bar", "foo", "true", // comparison - "5", // length + " 5", // length "b", // split("/")[1] "%F0%9F%90%B6", // dog emoji, uri-encoded "🐶", // uri-encoded dog emoji, decoded @@ -299,7 +299,7 @@ describe("end to end brightscript functions", () => { ` id: "someId"\n` + `}`, 'getNamedElementsCi("child1") count = ', - "2", + " 2", "name of first child = ", "Child1", "mame of second child = ", @@ -315,25 +315,25 @@ describe("end to end brightscript functions", () => { "node.baseBoolField: ", "false", "node.baseIntField: ", - "0", + " 0", "node.normalBoolField: ", "true", "node.advancedStringField: ", "advancedField!", "node.advancedIntField: ", - "12345", + " 12345", "node child count is: ", - "6", + " 6", "child id is: ", "normalLabel", "otherNode child count is: ", - "3", + " 3", "anotherNode child count is: ", - "1", + " 1", "baseRectangle width: ", - "100", + " 100", "baseRectangle height: ", - "200", + " 200", ]); }); @@ -371,15 +371,15 @@ describe("end to end brightscript functions", () => { "Double value ", "123.456", "Double value * 2 ", - "246.912", + " 246.912", "Float object ", "789.012", "Float object * 10 ", - "7890.12", + " 7890.12", "Integer object ", "23", "Integer object times itself ", - "529", + " 529", "Double to string ", "123.456", "Float to string ", @@ -416,7 +416,7 @@ describe("end to end brightscript functions", () => { "group node visible:", "true", "group node opacity:", - "1", + " 1", "extended group node type:", "Node", "extended group node subtype:", @@ -424,9 +424,9 @@ describe("end to end brightscript functions", () => { "extended group node visible:", "true", "extended group node opacity:", - "1", + " 1", "group as child node rotation:", - "0.2", + " 0.2", ]); }); @@ -458,13 +458,13 @@ describe("end to end brightscript functions", () => { "rectangle node subtype:", "Rectangle", "rectangle node width:", - "0", + " 0", "rectangle node height:", - "0", + " 0", "rectangle as child width:", - "500", + " 500", "rectangle as child height:", - "50", + " 50", ]); }); @@ -479,13 +479,13 @@ describe("end to end brightscript functions", () => { "label node horizAlign:", "left", "label node numLines:", - "0", + " 0", "label as child numLines:", - "10", + " 10", "label as child wrap:", "true", "label as child lineSpacing:", - "5.5", + " 5.5", ]); }); @@ -502,7 +502,7 @@ describe("end to end brightscript functions", () => { "timer node repeat:", "false", "timer node duration:", - "0", + " 0", "timer node fire:", "", ]); @@ -519,11 +519,11 @@ describe("end to end brightscript functions", () => { "font node uri:", "", "font node size:", - "1", + " 1", "font node fallbackGlyph:", "", "font as child size:", - "56", + " 56", "font as child uri:", "font/as/child/uri", ]); @@ -538,15 +538,15 @@ describe("end to end brightscript functions", () => { "poster node subtype:", "Poster", "poster node width:", - "0", + " 0", "poster node height:", - "0", + " 0", "poster as child audioGuideText:", "fake text", "poster as child uri:", "/fake/uri", "poster as child bitmapWidth:", - "10.4", + " 10.4", ]); }); @@ -559,13 +559,13 @@ describe("end to end brightscript functions", () => { "arraygrid node subtype:", "ArrayGrid", "arraygrid node focusRow:", - "0", + " 0", "arraygrid node jumpToItem:", - "0", + " 0", "arraygrid as child wrapDividerWidth", - "1.23", + " 1.23", "arraygrid as child numRows", - "5", + " 5", ]); }); @@ -578,11 +578,11 @@ describe("end to end brightscript functions", () => { "markupgrid node subtype:", "MarkupGrid", "markupgrid node numRows:", - "12", + " 12", "markupgrid node sectionDividerMinWidth:", - "117", + " 117", "markupgridAsChild numColumns:", - "10", + " 10", "markupgridAsChild fixedLayout:", "true", ]); @@ -611,7 +611,7 @@ describe("end to end brightscript functions", () => { "child: event", "", "child: event.getData()", - "123", + " 123", "child: event.getField()", "intField", "child: event.getRoSGNode().subtype()", @@ -621,11 +621,11 @@ describe("end to end brightscript functions", () => { // changing a field multiple times "child: current event:", - "123", + " 123", "child: previous event:", - "123", + " 123", "child: current event:", - "456", + " 456", ]); }); @@ -640,7 +640,7 @@ describe("end to end brightscript functions", () => { "contentnode.ContentType:", "", "contentnode.TargetRotation:", - "0", + " 0", "contentnodeAsChild.episodeNumber:", "10", "contentnodeAsChild.subtitleUrl:", @@ -671,14 +671,14 @@ describe("end to end brightscript functions", () => { "", "", "", - "0", + " 0", "", - "0", + " 0", "", "", "true", "", - "36", + " 36", "PST", "false", "en_US", @@ -688,9 +688,9 @@ describe("end to end brightscript functions", () => { "fr_CA", "fr_CA", "", - "0", - "0", - "0", + " 0", + " 0", + " 0", "true", "on", "default", @@ -704,24 +704,24 @@ describe("end to end brightscript functions", () => { "true", "", "", - "0", - "0", + " 0", + " 0", "", "", "", - "0", + " 0", "", - "0", - "0", + " 0", + " 0", "true", "mpeg4 avc", - "0", + " 0", "", "true", "", - "0", + " 0", "true", - "0", + " 0", "", "true", ]); @@ -794,9 +794,9 @@ describe("end to end brightscript functions", () => { "textEditBox hint text:", "", "textEditBox maxTextLength:", - "15", + " 15", "textEditBox cursorPosition:", - "0", + " 0", "textEditBox clearOnDownKey:", "true", "textEditBox active:", diff --git a/test/e2e/BrsMock.test.js b/test/e2e/BrsMock.test.js index 37d01426..1ff960eb 100644 --- a/test/e2e/BrsMock.test.js +++ b/test/e2e/BrsMock.test.js @@ -32,7 +32,7 @@ describe("e2e/resources/components/mocks", () => { expect(allArgs(outputStreams.stdout.write).filter((arg) => arg !== "\n")).toEqual([ "marking mock timespan", "mocked timespan should return 8: ", - "8", + " 8", "create object regex:", "roRegex", "mock object regex:", @@ -45,7 +45,7 @@ describe("e2e/resources/components/mocks", () => { "mocked node name:", "node-name", "mocked node child index:", - "333", + " 333", "second mock node id is not mutated by first mock:", "id", "second mock node name is not mutated by first mock:", @@ -66,23 +66,23 @@ describe("e2e/resources/components/mocks", () => { "--inline foo--", "doesn't exist in source yet here i am", "spyOnMe", - "1", - "2", + " 1", + " 2", "first string", - "123", - "1", + " 123", + " 1", "mocked implementation!", - "2", - "2", + " 2", + " 2", "second string", - "456", - "2", + " 456", + " 2", "mocked implementation!", - "0", - "0", - "1234", + " 0", + " 0", + " 1234", "foo", - "0", + " 0", "foo", "invalid", "invalid", diff --git a/test/e2e/CallFunc.test.js b/test/e2e/CallFunc.test.js index 1063d9d6..7295c6eb 100644 --- a/test/e2e/CallFunc.test.js +++ b/test/e2e/CallFunc.test.js @@ -24,7 +24,7 @@ describe("callFunc", () => { expect(allArgs(outputStreams.stdout.write).filter((arg) => arg !== "\n")).toEqual([ "component: inside oneArg, args.test: ", - "123", + " 123", "component: componentField:", "componentField value", "component: mainField:", @@ -38,15 +38,15 @@ describe("callFunc", () => { "invalid", "component: inside fiveArgs", "arg1: ", - "1", + " 1", "arg2: ", - "2", + " 2", "arg3: ", - "3", + " 3", "arg4: ", - "4", + " 4", "arg5: ", - "5", + " 5", "Inside parent function", "component: inside privateFunction", "private return value", diff --git a/test/e2e/ComponentGlobal.test.js b/test/e2e/ComponentGlobal.test.js index 713263c4..6505d237 100644 --- a/test/e2e/ComponentGlobal.test.js +++ b/test/e2e/ComponentGlobal.test.js @@ -22,7 +22,7 @@ describe("m.global usage in scenegraph components", () => { expect(allArgs(outputStreams.stdout.write).filter((arg) => arg !== "\n")).toEqual([ "inside component init, m.global.brsIntField: ", - "123", + " 123", "MGlobalWidget.text: ", "", "MUniversalWidget.text: ", diff --git a/test/e2e/ComponentTop.test.js b/test/e2e/ComponentTop.test.js index ba747bb9..ecffefb0 100644 --- a/test/e2e/ComponentTop.test.js +++ b/test/e2e/ComponentTop.test.js @@ -28,8 +28,8 @@ describe("m.top usage in scenegraph components", () => { "this is a default value defined in xml", "true", "false", - "300", - "100", + " 300", + " 100", "this value set using m.top", "invalid", ]); diff --git a/test/e2e/Functions.test.js b/test/e2e/Functions.test.js index 9a2912e1..7bba7ca2 100644 --- a/test/e2e/Functions.test.js +++ b/test/e2e/Functions.test.js @@ -23,15 +23,15 @@ describe("end to end functions", () => { expect(allArgs(outputStreams.stdout.write).filter((arg) => arg !== "\n")).toEqual([ "noArgsFunc", "requiredArgsFunc:", - "1", - "2", + " 1", + " 2", "typedArgsFunc:", - "2.5", - "3", + " 2.5", + " 3", "false", "optionalArgsFunc:", "-5", - "2", + " 2", "-10", ]); }); @@ -42,13 +42,13 @@ describe("end to end functions", () => { expect(allArgs(outputStreams.stdout.write).filter((arg) => arg !== "\n")).toEqual([ "staticReturn", "conditionalReturn:", - "5", + " 5", "conditionalReturn:", "invalid", "forLoopReturn:", - "2", + " 2", "whileLoopReturn:", - "3", + " 3", "boxedReturnType:", "roFloat", "3.14159", @@ -66,7 +66,7 @@ describe("end to end functions", () => { "immediately-invoked function expression (IIFE)", "pre-callback", "callback:", - "14", + " 14", "post-callback", ]); }); diff --git a/test/e2e/Iterables.test.js b/test/e2e/Iterables.test.js index cd0a8cd7..465c4bbb 100644 --- a/test/e2e/Iterables.test.js +++ b/test/e2e/Iterables.test.js @@ -21,11 +21,11 @@ describe("end to end iterables", () => { await execute([resourceFile("arrays.brs")], outputStreams); expect(allArgs(outputStreams.stdout.write).filter((arg) => arg !== "\n")).toEqual([ - "1", - "4", - "9", // squared values, via for-each - "27", // two-dimensional index - "16", // 2 ^ 4 + " 1", + " 4", + " 9", // squared values, via for-each + " 27", // two-dimensional index + " 16", // 2 ^ 4 "foo bar", // oneDimensional[0] += " bar" ]); }); @@ -40,13 +40,13 @@ describe("end to end iterables", () => { "secondLayer", // twoDimensional.secondLayer.level - "2", + " 2", // after adding a third layer, twoDimensional.secondLayer.thirdLayer.level - "3", + " 3", // modify twoDimensional.secondLayer.level to sanity-check *= and friends - "6", + " 6", // add `false` via expression to `empty` "false", diff --git a/test/e2e/Localization.test.js b/test/e2e/Localization.test.js index 9c5499a2..06bf9a4d 100644 --- a/test/e2e/Localization.test.js +++ b/test/e2e/Localization.test.js @@ -28,7 +28,7 @@ describe("Localization", () => { "hello", "Au revoir", "world", - "123", + " 123", ]); }); }); diff --git a/test/e2e/RoSGNode.test.js b/test/e2e/RoSGNode.test.js index bdc35420..10ec50a3 100644 --- a/test/e2e/RoSGNode.test.js +++ b/test/e2e/RoSGNode.test.js @@ -92,11 +92,11 @@ describe("components/roSGNode", () => { expect(allArgs(outputStreams.stdout.write).filter((arg) => arg !== "\n")).toEqual([ "node size: ", - "7", + " 7", "node keys size: ", - "7", + " 7", "node items size: ", - "7", + " 7", "can delete elements: ", "true", "can look up elements: ", @@ -111,15 +111,15 @@ describe("components/roSGNode", () => { "true", //ifNodeField tests "node size: ", - "3", + " 3", "node size: ", - "2", + " 2", "field3 in node is: ", "false", "field3 in node now is: ", "true", "number of fields, via getFields().count(): ", - "2", + " 2", "field1 in node now is: ", "hello", "field3 in node now is: ", @@ -133,51 +133,51 @@ describe("components/roSGNode", () => { "field 3 updated", //ifNodeChildren tests "parent child count: ", - "0", + " 0", "get same parent from child: ", "true", "parent child count: ", - "1", + " 1", "parent child count: ", - "2", + " 2", "parent child count: ", - "3", + " 3", "parent child count: ", - "2", + " 2", "children size: ", - "2", + " 2", "first child id after replacing: ", "new node", "parent child count: ", - "2", + " 2", "parent child count: ", - "2", + " 2", "parent child count: ", - "0", + " 0", "parent child count: ", - "3", + " 3", "parent child count: ", - "0", + " 0", "parent child count: ", - "2", + " 2", "parent child count: ", - "3", + " 3", "parent child count: ", - "4", + " 4", "parent child count: ", - "4", + " 4", "parent child count: ", - "6", + " 6", "parent child count: ", - "4", + " 4", "inserted child id: ", "new node", "parent child count: ", - "4", + " 4", "new parent id: ", "new node", "new child count after reparent: ", - "1", + " 1", //ifNodeDict tests "find node that does not exist: ", "invalid", @@ -207,12 +207,12 @@ describe("components/roSGNode", () => { "newValue", "updatedId", "invalid", - "33", - "37", - "0", - "0", - "0", - "0", + " 33", + " 37", + " 0", + " 0", + " 0", + " 0", ]); }); }); diff --git a/test/e2e/StdLib.test.js b/test/e2e/StdLib.test.js index 58a32583..cff130ce 100644 --- a/test/e2e/StdLib.test.js +++ b/test/e2e/StdLib.test.js @@ -41,23 +41,23 @@ describe("end to end standard libary", () => { expect(allArgs(outputStreams.stdout.write).filter((arg) => arg !== "\n")).toEqual([ "MIXED CASE", "mixed case", - "12359", + " 12359", "ぇ", "Mixed", "Case", - "10", + " 10", "ed", - "7", - "10", + " 7", + " 10", " 3.4", " 9.7", "-3", - "12.34", - "0", - "255", - "170", + " 12.34", + " 0", + " 255", + " 170", "Mary and Bob", - "252", + " 252", "abababab", "!!!!!!!!", ]); @@ -67,20 +67,20 @@ describe("end to end standard libary", () => { await execute([resourceFile("stdlib", "math.brs")], outputStreams); expect(allArgs(outputStreams.stdout.write).filter((arg) => arg !== "\n")).toEqual([ - "22.19795", - "2.85647", - "3.342155", - "0.4636476", - "0.7073883", - "0.9999997", - "0.999204", - "3.5", - "17", - "17", - "204", + " 22.19795", + " 2.85647", + " 3.342155", + " 0.4636476", + " 0.7073883", + " 0.9999997", + " 0.999204", + " 3.5", + " 17", + " 17", + " 204", "-2", - "7", - "1", + " 7", + " 1", "-1", ]); }); @@ -119,7 +119,7 @@ describe("end to end standard libary", () => { " in runme.brs", "returned to run.brs", "runme.brs returned: ", - "2", + " 2", ]); }); diff --git a/test/e2e/Syntax.test.js b/test/e2e/Syntax.test.js index fde1ea43..0afe261a 100644 --- a/test/e2e/Syntax.test.js +++ b/test/e2e/Syntax.test.js @@ -29,13 +29,13 @@ describe("end to end syntax", () => { "invalid", "true", "false", - "5", - "6", - "7", - "30", - "40", + " 5", + " 6", + " 7", + " 30", + " 40", "hello", - "255", + " 255", ]); }); @@ -43,34 +43,34 @@ describe("end to end syntax", () => { await execute([resourceFile("arithmetic.brs")], outputStreams); expect(allArgs(outputStreams.stdout.write).filter((arg) => arg !== "\n")).toEqual([ - "3", - "3", - "3", - "3", // addition - "5", - "5", - "5", - "5", // subtraction - "15", - "15", - "15", - "15", // multiplication - "2.5", - "2", - "2.5", - "2.5", // division - "8", - "8", - "8", - "8", // exponentiation - "64", - "128", - "256", - "16", - "8", - "4", + " 3", + " 3", + " 3", + " 3", // addition + " 5", + " 5", + " 5", + " 5", // subtraction + " 15", + " 15", + " 15", + " 15", // multiplication + " 2.5", + " 2", + " 2.5", + " 2.5", // division + " 8", + " 8", + " 8", + " 8", // exponentiation + " 64", + " 128", + " 256", + " 16", + " 8", + " 4", "-5", // unary + and - - "5", + " 5", "-5", ]); }); @@ -80,7 +80,7 @@ describe("end to end syntax", () => { expect(allArgs(outputStreams.stdout.write).filter((arg) => arg !== "\n")).toEqual([ "0000", - "0", + " 0", "foo is not 1", ]); }); @@ -97,11 +97,11 @@ describe("end to end syntax", () => { await execute([resourceFile("assignment-operators.brs")], outputStreams); expect(allArgs(outputStreams.stdout.write).filter((arg) => arg !== "\n")).toEqual([ - "5", - "2", - "6", - "3", - "1", + " 5", + " 2", + " 6", + " 3", + " 1", ]); }); @@ -109,14 +109,14 @@ describe("end to end syntax", () => { await execute([resourceFile("conditionals.brs")], outputStreams); expect(allArgs(outputStreams.stdout.write).filter((arg) => arg !== "\n")).toEqual([ - "1", - "2", - "3", - "4", - "5", - "6", - "7", - "8", + " 1", + " 2", + " 3", + " 4", + " 5", + " 6", + " 7", + " 8", // testing if not "not false", "bar does not equal 'def'", @@ -131,8 +131,8 @@ describe("end to end syntax", () => { "foo is not < 2", "foo is not < 2 and not > 2", "#481 fixed", - "2", - "5", + " 2", + " 5", ]); }); @@ -140,9 +140,9 @@ describe("end to end syntax", () => { await execute([resourceFile("dim.brs")], outputStreams); expect(allArgs(outputStreams.stdout.write).filter((arg) => arg !== "\n")).toEqual([ - "4", - "5", - "5", + " 4", + " 5", + " 5", "hello", "invalid", "invalid", @@ -153,14 +153,14 @@ describe("end to end syntax", () => { await execute([resourceFile("while-loops.brs")], outputStreams); expect(allArgs(outputStreams.stdout.write).filter((arg) => arg !== "\n")).toEqual([ - "0", - "1", - "2", - "3", - "4", // count up - "5", - "4", // count down with exit - "15", // compute 3 * 5 with nested loops + " 0", + " 1", + " 2", + " 3", + " 4", // count up + " 5", + " 4", // count down with exit + " 15", // compute 3 * 5 with nested loops ]); }); @@ -168,19 +168,19 @@ describe("end to end syntax", () => { await execute([resourceFile("for-loops.brs")], outputStreams); expect(allArgs(outputStreams.stdout.write).filter((arg) => arg !== "\n")).toEqual([ - "0", - "2", - "4", - "6", // count up - "8", // i after loop - "3", - "2", - "1", - "0", // count down - "128", // step non multiple of final - "85", // step non multiple of final + " 0", + " 2", + " 4", + " 6", // count up + " 8", // i after loop + " 3", + " 2", + " 1", + " 0", // count down + " 128", // step non multiple of final + " 85", // step non multiple of final "for loop exit", // exit early - "0", // e after loop + " 0", // e after loop "initial = final", // loop where initial equals final ]); }); @@ -189,15 +189,15 @@ describe("end to end syntax", () => { await execute([resourceFile("print.brs")], outputStreams); expect(allArgs(outputStreams.stdout.write).join("")).toEqual( - "lorem 1psum\n" + - "9 is equal to 9\n" + + "lorem 1psum\n" + + " 9 is equal to 9\n" + // 0 0 0 1 1 2 2 2 3 3 4 4 4 5 5 // 0 4 8 2 6 0 4 8 2 6 0 4 8 2 6 "column a column b column c column d\n" + // 0 0 0 1 1 2 2 2 3 3 4 4 4 5 5 // 0 4 8 2 6 0 4 8 2 6 0 4 8 2 6 " I started at col 3 I started at col 25\n" + - "01234\n" + + "0123 4\n" + "lorem ipsum dolor sit amet\n" + "no newline" ); @@ -214,7 +214,7 @@ describe("end to end syntax", () => { "stop", "then", "Hello from line ", - "14", + " 14", ]); }); @@ -222,9 +222,9 @@ describe("end to end syntax", () => { await execute([resourceFile("increment.brs")], outputStreams); expect(allArgs(outputStreams.stdout.write).filter((arg) => arg !== "\n")).toEqual([ - "6", // var = 5: var++ - "2", // aa = { foo: 3 }: aa.foo-- - "14", // arr = [13]: arr[0]++ + " 6", // var = 5: var++ + " 2", // aa = { foo: 3 }: aa.foo-- + " 14", // arr = [13]: arr[0]++ ]); }); @@ -241,11 +241,11 @@ describe("end to end syntax", () => { await execute([resourceFile("try-catch.brs")], outputStreams); expect(allArgs(outputStreams.stdout.write).filter((arg) => arg !== "\n")).toEqual([ "[pre_try] a = ", - "5", + " 5", "[in_try] a = ", - "10", + " 10", "[post_try] a = ", - "10", + " 10", ]); }); }); diff --git a/test/e2e/TypeChecking.test.js b/test/e2e/TypeChecking.test.js index 57625b0c..a34462c3 100644 --- a/test/e2e/TypeChecking.test.js +++ b/test/e2e/TypeChecking.test.js @@ -127,25 +127,25 @@ describe("function argument type checking", () => { .filter((s) => !!s) ).toEqual([ "assigning RHS of type 'double' with value: 2.71828", - "integer% = 2", - "float! = 2.71828", - "double# = 2.71828", - "longinteger& = 2", + "integer% = 2", + "float! = 2.71828", + "double# = 2.71828", + "longinteger& = 2", "assigning RHS of type 'float' with value: 3.14159", - "integer% = 3", - "float! = 3.14159", - "double# = 3.14159", - "longinteger& = 3", + "integer% = 3", + "float! = 3.14159", + "double# = 3.14159", + "longinteger& = 3", "assigning RHS of type 'integer' with value: 13", - "integer% = 13", - "float! = 13", - "double# = 13", - "longinteger& = 13", + "integer% = 13", + "float! = 13", + "double# = 13", + "longinteger& = 13", "assigning RHS of type 'longinteger' with value: 2147483647119", "integer% = -881", - "float! = 2147484000000", - "double# = 2147483647119", - "longinteger& = 2147483647119", + "float! = 2147484000000", + "double# = 2147483647119", + "longinteger& = 2147483647119", ]); }); }); diff --git a/test/interpreter/PrintStatements.test.js b/test/interpreter/PrintStatements.test.js index da695bf1..efd1063d 100644 --- a/test/interpreter/PrintStatements.test.js +++ b/test/interpreter/PrintStatements.test.js @@ -101,7 +101,7 @@ describe("interperter print statements", () => { const [result] = interpreter.exec([ast]); expect(result).toEqual(BrsInvalid.Instance); - expect(allArgs(stdout.write).join("")).toEqual("foo 4\n"); + expect(allArgs(stdout.write).join("")).toEqual("foo 4\n"); }); it("indents to an arbitrary position via `tab`", () => {