PageRenderTime 45ms CodeModel.GetById 20ms RepoModel.GetById 1ms app.codeStats 0ms

/test/blanket_test.js

https://github.com/morkai/blanket
JavaScript | 48 lines | 39 code | 9 blank | 0 comment | 1 complexity | 31405ac7c1321e67fbeccf413cbab301 MD5 | raw file
Possible License(s): MIT
  1. test( "blanket instrument", function() {
  2. expect(2);
  3. var infile = "var a=1;if(a==1){a=2;}if(a==3){a=4;}console.log(a);";
  4. var infilename= "testfile";
  5. blanket.instrument({
  6. inputFile: infile,
  7. inputFileName: infilename
  8. },function(instrumented){
  9. ok( instrumented.length > infile.length, "instrumented." );
  10. ok(instrumented.indexOf("_$blanket['"+infilename+"']") > -1,"added enough instrumentation.");
  11. });
  12. });
  13. test( "blanket instrument elseif block", function() {
  14. expect(1);
  15. var expected = 4,
  16. result;
  17. var infile = "var a=3;if(a==1){a=2;}else if(a==3){a="+expected+";}\nresult=a;";
  18. var infilename= "testfile2";
  19. blanket.instrument({
  20. inputFile: infile,
  21. inputFileName: infilename
  22. },function(instrumented){
  23. eval(instrumented);
  24. ok( result == expected, "instrumented properly." );
  25. });
  26. });
  27. test( "blanket instrument for in", function() {
  28. expect(1);
  29. var result;
  30. var infile = "var arr=[]; result = window.alert ? (function() {\n for ( var key in arr ) {\n arr[ key ]=0; \n}return true; \n})() : false;";
  31. var infilename= "testfile3";
  32. blanket.instrument({
  33. inputFile: infile,
  34. inputFileName: infilename
  35. },function(instrumented){
  36. eval(instrumented);
  37. ok( result, "instrumented properly." );
  38. });
  39. });