Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tests for extension functions #1344

Merged
merged 1 commit into from
Jan 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions src/types/__snapshots__/resolveDescriptors.spec.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,44 @@ Line 4, col 17:
"
`;

exports[`resolveDescriptors should fail descriptors for extend-fun-cannot-be-defined-within-contract 1`] = `
"<unknown>:3:5: Extend functions cannot be defined within a contract
Line 3, col 5:
2 | contract Foo {
> 3 | extends fun Bar(self: Int, a: Int): Int {}
^~~~~~~
4 | }
"
`;

exports[`resolveDescriptors should fail descriptors for extend-fun-cannot-be-defined-within-trait 1`] = `
"<unknown>:3:5: Extend functions cannot be defined within a contract
Line 3, col 5:
2 | trait Foo {
> 3 | extends fun Bar(self: Int, a: Int): Int {}
^~~~~~~
4 | }
"
`;

exports[`resolveDescriptors should fail descriptors for extend-fun-missing-type 1`] = `
"<unknown>:1:32: Type "Bar" not found
Line 1, col 32:
> 1 | extends fun Foo(self: String): Bar {
^~~
2 | return "";
"
`;

exports[`resolveDescriptors should fail descriptors for extend-fun-must-have-at-least-one-parameter 1`] = `
"<unknown>:2:1: Extend functions must have at least one parameter
Line 2, col 1:
1 | primitive Int;
> 2 | extends fun Bar(): Int {}
^~~~~~~
"
`;

exports[`resolveDescriptors should fail descriptors for getter-outside-contract 1`] = `
"<unknown>:8:1: Getters must be defined within a contract
Line 8, col 1:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
primitive Int;
contract Foo {
extends fun Bar(self: Int, a: Int): Int {}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
primitive Int;
trait Foo {
extends fun Bar(self: Int, a: Int): Int {}
}
3 changes: 3 additions & 0 deletions src/types/test-failed/extend-fun-missing-type.tact
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
extends fun Foo(self: String): Bar {
return "";
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
primitive Int;
extends fun Bar(): Int {}
Loading