Skip to content

Commit

Permalink
Add simple tests, fix formatting.
Browse files Browse the repository at this point in the history
  • Loading branch information
RZhang05 committed Oct 10, 2024
1 parent 26428cb commit c81e69c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
3 changes: 1 addition & 2 deletions runtime/sema/gen/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -814,8 +814,7 @@ func (g *generator) VisitInterfaceDeclaration(decl *ast.InterfaceDeclaration) (_
// func init() {
// members := []*Member{...}
// t.Members = MembersAsMap(members)
// t.Fields = MembersFieldNames(members)
// t.ConstructorParameters = ...
// t.Fields = MembersFieldNames(members)=
// }

members := membersExpr(
Expand Down
10 changes: 8 additions & 2 deletions runtime/tests/checker/stringer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func TestCheckStringer(t *testing.T) {
let c: {StructStringer} = "hey"
access(all)
struct Foo: StructStringer {
view fun toString():String {
view fun toString(): String {
return "foo"
}
}
Expand All @@ -58,12 +58,18 @@ func TestCheckInvalidStringer(t *testing.T) {
let b: {StructStringer} = [<-create R()]
let c: {StructStringer} = {1: true}
struct Foo: StructStringer {}
struct Bar: StructStringer {
fun toString(): String {
return "bar"
}
}
`)

errs := RequireCheckerErrors(t, err, 4)
errs := RequireCheckerErrors(t, err, 5)

assert.IsType(t, &sema.TypeMismatchError{}, errs[0])
assert.IsType(t, &sema.TypeMismatchError{}, errs[1])
assert.IsType(t, &sema.TypeMismatchError{}, errs[2])
assert.IsType(t, &sema.ConformanceError{}, errs[3])
assert.IsType(t, &sema.ConformanceError{}, errs[4])
}

0 comments on commit c81e69c

Please sign in to comment.