-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add tests w/ current temporary lifetime behavior
(for better or worse)
- Loading branch information
1 parent
7779749
commit 96a96d8
Showing
12 changed files
with
41 additions
and
0 deletions.
There are no files selected for viewing
18 changes: 18 additions & 0 deletions
18
dada_tests/specifier/temporary-lifetime/call-argument.dada
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,18 @@ | ||
class Object(any data) | ||
|
||
async fn main() { | ||
any o = lease_me(Object(22)).data | ||
#! RUN ERROR your lease to this object was cancelled | ||
# | ||
# What happens here: | ||
# * the `Object(22)` is stored into a temporary that is dropped as soon | ||
# as the call completes. | ||
# | ||
#! FIXME: This seems kind of annoying! | ||
|
||
print(o).await | ||
} | ||
|
||
fn lease_me(leased p) { | ||
p | ||
} |
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 @@ | ||
[] |
Empty file.
Empty file.
12 changes: 12 additions & 0 deletions
12
dada_tests/specifier/temporary-lifetime/if-then-else-leased.dada
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,12 @@ | ||
class Object(any data) | ||
|
||
async fn main() { | ||
any o = if true { Object(true).lease } else { Object(false).lease } | ||
#! RUN ERROR your lease to this object was cancelled | ||
# | ||
# What happens here: | ||
# * `Object(true).lease` is equivalent to `{ any o = Object(true); o.lease }` | ||
# * that variable `o` is dropped as we exit the `if-then-else` | ||
|
||
print(o).await | ||
} |
1 change: 1 addition & 0 deletions
1
dada_tests/specifier/temporary-lifetime/if-then-else-leased/lsp.ref
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 @@ | ||
[] |
Empty file.
Empty file.
7 changes: 7 additions & 0 deletions
7
dada_tests/specifier/temporary-lifetime/if-then-else-owned.dada
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,7 @@ | ||
class Object(any data) | ||
|
||
async fn main() { | ||
# This is equivalent to `if { .. } else { .. }.lease`. | ||
leased o = if true { Object(true) } else { Object(false) } | ||
print(o).await #! OUTPUT Object\(true\) | ||
} |
1 change: 1 addition & 0 deletions
1
dada_tests/specifier/temporary-lifetime/if-then-else-owned/lsp.ref
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 @@ | ||
[] |
Empty file.
1 change: 1 addition & 0 deletions
1
dada_tests/specifier/temporary-lifetime/if-then-else-owned/stdout.ref
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 @@ | ||
leased Object(true) |