Skip to content

Commit 8a9a175

Browse files
committed
Ensure all object asserts are executed, fix #181
1 parent 461233f commit 8a9a175

File tree

5 files changed

+57
-1
lines changed

5 files changed

+57
-1
lines changed

core/vm.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -872,6 +872,7 @@ class Interpreter {
872872
if (stack.alreadyExecutingInvariants(self)) return;
873873

874874
unsigned counter = 0;
875+
unsigned initial_stack_size = stack.size();
875876
stack.newFrame(FRAME_INVARIANTS, loc);
876877
std::vector<HeapThunk*> &thunks = stack.top().thunks;
877878
objectInvariants(self, self, counter, thunks);
@@ -880,7 +881,6 @@ class Interpreter {
880881
return;
881882
}
882883
HeapThunk *thunk = thunks[0];
883-
unsigned initial_stack_size = stack.size();
884884
stack.top().elementId = 1;
885885
stack.top().self = self;
886886
stack.newCall(loc, thunk, thunk->self, thunk->offset, thunk->upValues);
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/*
2+
Copyright 2015 Google Inc. All rights reserved.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
local x = "foo";
18+
local y = "bar";
19+
20+
{ assert true, assert x == y, x: 1 } == { x: 1 } &&
21+
22+
true
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
RUNTIME ERROR: Object assertion failed.
2+
error.obj_assert.fail1.jsonnet:20:23-28 thunk <object_assert>
3+
std.jsonnet:976:54-57 thunk <a>
4+
std.jsonnet:976:54-65 function <anonymous>
5+
std.jsonnet:976:54-65 function <anonymous>
6+
std.jsonnet:980:21-32
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/*
2+
Copyright 2015 Google Inc. All rights reserved.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
local x = "foo";
18+
local y = "bar";
19+
20+
{ assert true, assert x == y : "%s was not equal to %s" % [x, y], x: 1 } == { x: 1 } &&
21+
22+
true
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
RUNTIME ERROR: foo was not equal to bar
2+
error.obj_assert.fail2.jsonnet:20:32-64 thunk <object_assert>
3+
std.jsonnet:976:54-57 thunk <a>
4+
std.jsonnet:976:54-65 function <anonymous>
5+
std.jsonnet:976:54-65 function <anonymous>
6+
std.jsonnet:980:21-32

0 commit comments

Comments
 (0)