Revision 8843af72fcf88e2bfd6f16dd95688ffc9d2c9db6 authored by keilr on 17 September 2014, 14:30:02 UTC, committed by keilr on 17 September 2014, 14:30:02 UTC
git-svn-id: https://proglang.informatik.uni-freiburg.de/svn/proglang/projects/jsproxy/branches/TreatJS@24784 e3db86c2-31ce-0310-bca5-be3edd1b5589
1 parent 324e37b
debugger.js
/*
* TreatJS: Higher-Order Contracts for JavaScript
* http://proglang.informatik.uni-freiburg.de/treatjs/
*
* Copyright (c) 2014, Proglang, University of Freiburg.
* http://proglang.informatik.uni-freiburg.de/treatjs/
* All rights reserved.
*
* Released under the MIT license
* http://proglang.informatik.uni-freiburg.de/treatjs/license
*
* Author Matthias Keil
* http://www.informatik.uni-freiburg.de/~keilr/
*/
// Note: Still Testing Code
function TreatJSDebugger() {
if(!(this instanceof TreatJSDebugger)) return new TreatJSDebugger();
// TODO
this.catch = function(result) {
}
this.error = function(msg, file, line) {}
this.violation = function(msg, file, line) {}
this.blame = function(contract, msg, file, line) {}
}
function TreatJSDebuggerUnit() {
if(!(this instanceof TreatJSDebugger)) return new TreatJSDebugger();
else TreatJSDebugger.call(this);
var errorStack = new Array();
var violationStack = new Array();
var blameStack = new Array();
this.error = function(msg, file, line) {
errorStack.push("Error (" + file + ":" + line + "):\n" + msg);
}
this.violation = function(msg, file, line) {
violationStack.push("Error (" + file + ":" + line + "):\n" + msg);
}
this.blame = function(contract, msg, file, line) {
blameStack.push(
("Violation: (" + file + ":" + line + "):\n" + msg) + "\n" +
("Violated Contract: " + contract.toString())
);
}
function assertTrue(stack) {
var result = stack.pop();
if(!result) {
print(new Error().stack);
quit();
}
clear(stack);
}
function assertFalse(stack) {
var result = stack.pop();
print("RESULT " + result);
if(!result) {
print(new Error().stack);
quit();
} else {
print("" + result);
}
clear(stack);
}
function clear(stack) {
while(stack.length > 0) {
stack.pop();
}
}
this.assertNoError = function() {
assertTrue(errorStack);
}
this.assertError = function() {
assertFalse(errorStack);
}
this.assertNoViolation = function() {
assertTrue(violationStack);
}
this.assertViolation = function() {
assertFalse(violationStack);
}
this.assertNoBlame = function() {
assertTrue(blameStack);
}
this.assertBlame = function() {
assertFalse(blameStack);
}
}
TreatJSDebuggerUnit.prototype = new TreatJSDebugger();
Computing file changes ...