add regression tests for #20611

This commit is contained in:
tintinweb 2020-01-31 15:50:07 +01:00
parent 15d09038a6
commit b09b9f55fc

View file

@ -63,6 +63,46 @@ func runTrace(tracer *Tracer) (json.RawMessage, error) {
return tracer.GetResult() return tracer.GetResult()
} }
func TestRegressionPanicSlice(t *testing.T) {
tracer, err := New("{depths: [], step: function(log) { this.depths.push(log.memory.slice(-1,-2)); }, fault: function() {}, result: function() { return this.depths; }}")
if err != nil {
t.Fatal(err)
}
ret, err := runTrace(tracer)
if err != nil {
t.Fatal(err)
}
t.Logf("Got result %s", string(ret))
}
func TestRegressionPanicPeek(t *testing.T) {
tracer, err := New("{depths: [], step: function(log) { this.depths.push(log.stack.peek(-1)); }, fault: function() {}, result: function() { return this.depths; }}")
if err != nil {
t.Fatal(err)
}
ret, err := runTrace(tracer)
if err != nil {
t.Fatal(err)
}
t.Logf("Expected return value to be [0,1,2], got %s", string(ret))
}
func TestRegressionPanicGetUint(t *testing.T) {
tracer, err := New("{ depths: [], step: function(log, db) { this.depths.push(log.memory.getUint(-64));}, fault: function() {}, result: function() { return this.depths; }}")
if err != nil {
t.Fatal(err)
}
ret, err := runTrace(tracer)
if err != nil {
t.Fatal(err)
}
t.Logf("Expected return value to be [0,1,2], got %s", string(ret))
}
func TestTracing(t *testing.T) { func TestTracing(t *testing.T) {
tracer, err := New("{count: 0, step: function() { this.count += 1; }, fault: function() {}, result: function() { return this.count; }}") tracer, err := New("{count: 0, step: function() { this.count += 1; }, fault: function() {}, result: function() { return this.count; }}")
if err != nil { if err != nil {