Browse Source

Fix integer not being trunced when read from input

Fix domConsole not processing output as string
Lucas de Souza 5 years ago
parent
commit
b6bb750f65
2 changed files with 3 additions and 2 deletions
  1. 2 1
      js/io/domConsole.js
  2. 1 1
      js/processor/lib/io.js

+ 2 - 1
js/io/domConsole.js

@@ -125,7 +125,8 @@ export class DOMConsole {
   }
 
   sendOutput (text) {
-    text.split("\n").forEach(t => {
+    const output = ""+text;
+    output.split("\n").forEach(t => {
       t = t.replace(/\t/g,'	');
       this.write(t)
     });

+ 1 - 1
js/processor/lib/io.js

@@ -26,7 +26,7 @@ export function createInputFun () {
       let stoObj = null;
       if (typeToConvert.isCompatible(Types.INTEGER)) {
         const val = toInt(text);
-        stoObj = new StoreObject(Types.INTEGER, val);
+        stoObj = new StoreObject(Types.INTEGER, val.trunc());
       } else if (typeToConvert.isCompatible(Types.REAL)) {
         stoObj = new StoreObject(Types.REAL, toReal(text));
       } else if (typeToConvert.isCompatible(Types.BOOLEAN)) {