Browse Source

Fix test case n° 30 text

Include test case for switch...case fall through
Lucas de Souza 6 năm trước cách đây
mục cha
commit
c267a96359
2 tập tin đã thay đổi với 38 bổ sung1 xóa
  1. 1 1
      tests/test30.spec.js
  2. 37 0
      tests/test31.spec.js

+ 1 - 1
tests/test30.spec.js

@@ -3,7 +3,7 @@ import {Types} from './../js/ast/types';
 import { IVProgParser } from './../js/ast/ivprogParser';
 import { IVProgProcessor} from './../js/processor/ivprogProcessor'
 
-describe('A break command inside a for loop', function () {
+describe('A break command inside a switch..case', function () {
 
   let input = `programa {
 

+ 37 - 0
tests/test31.spec.js

@@ -0,0 +1,37 @@
+import Lexers from './../grammar/';
+import {Types} from './../js/ast/types';
+import { IVProgParser } from './../js/ast/ivprogParser';
+import { IVProgProcessor} from './../js/processor/ivprogProcessor'
+
+describe('A case without return/break', function () {
+
+  let input = `programa {
+
+    funcao inicio() {
+      inteiro a = 1
+      escolha (a) {
+        caso 0:
+          a = a + 1
+          pare
+        caso 1:
+          a = a + 2
+        caso 2:
+          a = a * 2
+          pare
+        caso contrario:
+          a = 5 + 8
+      }
+    }
+  }`;
+
+  const lexer = Lexers['pt_br'];
+
+  it(`should fall through`, function (done) {
+    const parser = new IVProgParser(input, lexer);
+    const exec = new IVProgProcessor(parser.parseTree());
+    exec.interpretAST().then(sto => {
+      expect(sto.applyStore('a').value).toEqual(6);
+      done();
+    }).catch( err => done(err));
+  });
+});