Front end of the Slack clone application.

optimistic.js 6.8KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. (function() {
  2. 'use strict';
  3. var escope, esprima, expect;
  4. expect = require('chai').expect;
  5. escope = require('..');
  6. esprima = require('esprima');
  7. describe('optimistic', function() {
  8. it('direct call to eval', function() {
  9. var ast, scopes;
  10. ast = esprima.parse("function outer() {\n eval(str);\n var i = 20;\n function inner() {\n i;\n }\n}");
  11. scopes = escope.analyze(ast, {
  12. optimistic: true
  13. }).scopes;
  14. return expect(scopes.map(function(scope) {
  15. return scope.variables.map(function(variable) {
  16. return variable.name;
  17. });
  18. })).to.be.eql([['outer'], ['arguments', 'i', 'inner'], ['arguments']]);
  19. });
  20. return it('with statement', function() {
  21. var ast, scopes;
  22. ast = esprima.parse("function outer() {\n eval(str);\n var i = 20;\n with (obj) {\n i;\n }\n}");
  23. scopes = escope.analyze(ast, {
  24. optimistic: true
  25. }).scopes;
  26. return expect(scopes.map(function(scope) {
  27. return scope.variables.map(function(variable) {
  28. return variable.name;
  29. });
  30. })).to.be.eql([['outer'], ['arguments', 'i'], []]);
  31. });
  32. });
  33. }).call(this);
  34. //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIm9wdGltaXN0aWMuY29mZmVlIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQXNCQztBQUFBLEVBQUEsWUFBQSxDQUFBO0FBQUEsTUFBQSx1QkFBQTs7QUFBQSxFQUVELE1BQUEsR0FBUyxPQUFBLENBQVMsTUFBVCxDQUFlLENBQUMsTUFGeEIsQ0FBQTs7QUFBQSxFQUdELE1BQUEsR0FBUyxPQUFBLENBQVMsSUFBVCxDQUhSLENBQUE7O0FBQUEsRUFJRCxPQUFBLEdBQVUsT0FBQSxDQUFTLFNBQVQsQ0FKVCxDQUFBOztBQUFBLEVBTUQsUUFBQSxDQUFVLFlBQVYsRUFBdUIsU0FBQSxHQUFBO0FBQ25CLElBQUEsRUFBQSxDQUF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NFIE9GXG4jIFRISVMgU09GVFdBUkUsIEVWRU4gSUYgQURWSVNFRCBPRiBUSEUgUE9TU0lCSUxJVFkgT0YgU1VDSCBEQU1BR0UuXG5cbid1c2Ugc3RyaWN0J1xuXG5leHBlY3QgPSByZXF1aXJlKCdjaGFpJykuZXhwZWN0XG5lc2NvcGUgPSByZXF1aXJlICcuLidcbmVzcHJpbWEgPSByZXF1aXJlICdlc3ByaW1hJ1xuXG5kZXNjcmliZSAnb3B0aW1pc3RpYycsIC0+XG4gICAgaXQgJ2RpcmVjdCBjYWxsIHRvIGV2YWwnLCAtPlxuICAgICAgICBhc3QgPSBlc3ByaW1hLnBhcnNlIFwiXCJcIlxuICAgICAgICBmdW5jdGlvbiBvdXRlcigpIHtcbiAgICAgICAgICAgIGV2YWwoc3RyKTtcbiAgICAgICAgICAgIHZhciBpID0gMjA7XG4gICAgICAgICAgICBmdW5jdGlvbiBpbm5lcigpIHtcbiAgICAgICAgICAgICAgICBpO1xuICAgICAgICAgICAgfVxuICAgICAgICB9XG4gICAgICAgIFwiXCJcIlxuXG4gICAgICAgIHNjb3BlcyA9IGVzY29wZS5hbmFseXplKGFzdCwgb3B0aW1pc3RpYzogeWVzKS5zY29wZXNcblxuICAgICAgICBleHBlY3Qoc2NvcGVzLm1hcCgoc2NvcGUpIC0+XG4gICAgICAgICAgICBzY29wZS52YXJpYWJsZXMubWFwKCh2YXJpYWJsZSkgLT4gdmFyaWFibGUubmFtZSkpKS50by5iZS5lcWwoXG4gICAgICAgICAgICBbXG4gICAgICAgICAgICAgICAgW1xuICAgICAgICAgICAgICAgICAgICAnb3V0ZXInXG4gICAgICAgICAgICAgICAgXVxuICAgICAgICAgICAgICAgIFtcbiAgICAgICAgICAgICAgICAgICAgJ2FyZ3VtZW50cydcbiAgICAgICAgICAgICAgICAgICAgJ2knXG4gICAgICAgICAgICAgICAgICAgICdpbm5lcidcbiAgICAgICAgICAgICAgICBdXG4gICAgICAgICAgICAgICAgW1xuICAgICAgICAgICAgICAgICAgICAnYXJndW1lbnRzJ1xuICAgICAgICAgICAgICAgIF1cbiAgICAgICAgICAgIF1cbiAgICAgICAgKVxuXG4gICAgaXQgJ3dpdGggc3RhdGVtZW50JywgLT5cbiAgICAgICAgYXN0ID0gZXNwcmltYS5wYXJzZSBcIlwiXCJcbiAgICAgICAgZnVuY3Rpb24gb3V0ZXIoKSB7XG4gICAgICAgICAgICBldmFsKHN0cik7XG4gICAgICAgICAgICB2YXIgaSA9IDIwO1xuICAgICAgICAgICAgd2l0aCAob2JqKSB7XG4gICAgICAgICAgICAgICAgaTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgfVxuICAgICAgICBcIlwiXCJcblxuICAgICAgICBzY29wZXMgPSBlc2NvcGUuYW5hbHl6ZShhc3QsIG9wdGltaXN0aWM6IHllcykuc2NvcGVzXG5cbiAgICAgICAgZXhwZWN0KHNjb3Blcy5tYXAoKHNjb3BlKSAtPlxuICAgICAgICAgICAgc2NvcGUudmFyaWFibGVzLm1hcCgodmFyaWFibGUpIC0+IHZhcmlhYmxlLm5hbWUpKSkudG8uYmUuZXFsKFxuICAgICAgICAgICAgW1xuICAgICAgICAgICAgICAgIFtcbiAgICAgICAgICAgICAgICAgICAgJ291dGVyJ1xuICAgICAgICAgICAgICAgIF1cbiAgICAgICAgICAgICAgICBbXG4gICAgICAgICAgICAgICAgICAgICdhcmd1bWVudHMnXG4gICAgICAgICAgICAgICAgICAgICdpJ1xuICAgICAgICAgICAgICAgIF1cbiAgICAgICAgICAgICAgICBbXG4gICAgICAgICAgICAgICAgXVxuICAgICAgICAgICAgXVxuICAgICAgICApXG5cblxuIl19