-
-
Notifications
You must be signed in to change notification settings - Fork 808
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into docs/range_bound
- Loading branch information
Showing
51 changed files
with
1,575 additions
and
374 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
from vyper.ast.metadata import NodeMetadata | ||
from vyper.exceptions import VyperException | ||
|
||
|
||
def test_metadata_journal_basic(): | ||
m = NodeMetadata() | ||
|
||
m["x"] = 1 | ||
assert m["x"] == 1 | ||
|
||
|
||
def test_metadata_journal_commit(): | ||
m = NodeMetadata() | ||
|
||
with m.enter_typechecker_speculation(): | ||
m["x"] = 1 | ||
|
||
assert m["x"] == 1 | ||
|
||
|
||
def test_metadata_journal_exception(): | ||
m = NodeMetadata() | ||
|
||
m["x"] = 1 | ||
try: | ||
with m.enter_typechecker_speculation(): | ||
m["x"] = 2 | ||
m["x"] = 3 | ||
|
||
assert m["x"] == 3 | ||
raise VyperException("dummy exception") | ||
|
||
except VyperException: | ||
pass | ||
|
||
# rollback upon exception | ||
assert m["x"] == 1 | ||
|
||
|
||
def test_metadata_journal_rollback_inner(): | ||
m = NodeMetadata() | ||
|
||
m["x"] = 1 | ||
with m.enter_typechecker_speculation(): | ||
m["x"] = 2 | ||
|
||
try: | ||
with m.enter_typechecker_speculation(): | ||
m["x"] = 3 | ||
m["x"] = 4 # test multiple writes | ||
|
||
assert m["x"] == 4 | ||
raise VyperException("dummy exception") | ||
|
||
except VyperException: | ||
pass | ||
|
||
assert m["x"] == 2 | ||
|
||
|
||
def test_metadata_journal_rollback_outer(): | ||
m = NodeMetadata() | ||
|
||
m["x"] = 1 | ||
try: | ||
with m.enter_typechecker_speculation(): | ||
m["x"] = 2 | ||
|
||
with m.enter_typechecker_speculation(): | ||
m["x"] = 3 | ||
m["x"] = 4 # test multiple writes | ||
|
||
assert m["x"] == 4 | ||
|
||
m["x"] = 5 | ||
|
||
raise VyperException("dummy exception") | ||
|
||
except VyperException: | ||
pass | ||
|
||
assert m["x"] == 1 |
Oops, something went wrong.