-
-
Notifications
You must be signed in to change notification settings - Fork 834
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' of https://github.com/vyperlang/vyper into refa…
…ctor/annotation
- Loading branch information
Showing
54 changed files
with
2,062 additions
and
406 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
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.