test17.spec.js 842 B

1234567891011121314151617181920212223242526272829303132
  1. import Lexers from './../grammar/';
  2. import * as Expressions from './../js/ast/expressions/';
  3. import * as Commands from './../js/ast/commands/';
  4. import {Types} from './../js/ast/types';
  5. import {
  6. IVProgParser
  7. } from './../js/ast/ivprogParser';
  8. describe('Variable declaration inside a function', () => {
  9. let input = `programa {
  10. funcao inicio() {
  11. inteiro a
  12. }
  13. }`;
  14. const lexer = Lexers['pt_br'];
  15. const ast = {
  16. global: [ ],
  17. functions: [
  18. new Commands.Function(null,Types.VOID,[],
  19. new Commands.CommandBlock([
  20. new Commands.Declaration('a',Types.INTEGER,null,false)],[]))
  21. ]
  22. }
  23. it(`must be inside the variables list`, () => {
  24. const as = new IVProgParser(input, lexer);
  25. const fun = as.parseTree();
  26. expect(fun).toEqual(ast);
  27. });
  28. });