Skip to content

Commit

Permalink
add enum test for invariant
Browse files Browse the repository at this point in the history
  • Loading branch information
Brat-vseznamus committed Oct 29, 2024
1 parent 3e0d434 commit 7da481e
Show file tree
Hide file tree
Showing 9 changed files with 40 additions and 0 deletions.
10 changes: 10 additions & 0 deletions internal/tlcodegen/test/codegen_test/goldmaster_invariants_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,27 @@ import "github.com/vkcom/tl/internal/tlcodegen/test/gen/goldmaster/meta"

func TestFunctionHasUnion(t *testing.T) {
{
// test type which contains union in its recursive definition
fun := meta.FactoryItemByTLName("service5.insertList")
if assert.NotNil(t, fun) {
assert.True(t, fun.IsFunction())
assert.True(t, fun.HasUnionTypesInResult())
}
}
{
// test type which doesn't contain union in its recursive definition
fun := meta.FactoryItemByTLName("usefulService.getUserEntity")
if assert.NotNil(t, fun) {
assert.True(t, fun.IsFunction())
assert.True(t, !fun.HasUnionTypesInResult())
}
}
{
// test type which contains enum in its recursive definition
fun := meta.FactoryItemByTLName("ab.call10")
if assert.NotNil(t, fun) {
assert.True(t, fun.IsFunction())
assert.True(t, fun.HasUnionTypesInResult())
}
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions internal/tlcodegen/test/gen/goldmaster/factory/factory.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions internal/tlcodegen/test/gen/goldmaster/meta/meta.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions internal/tlcodegen/test/gen/goldmaster/tlab/tlab.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 20 additions & 0 deletions internal/tlcodegen/test/gen/goldmaster/tljson.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ <h1>Functions</h1>
<code>ab.call1</code></a>
<code><a href="#AbTypeB">ab.TypeB</a></code>
</li>
<li>
<a href="#AbCall10">
<code>ab.call10</code></a>
<code><a href="#AColor">a.Color</a></code>
</li>
<li>
<a href="#AbCall2">
<code>ab.call2</code></a>
Expand Down Expand Up @@ -416,6 +421,21 @@ <h2 id="AbCall1">ab.call1</h2>
</dd>
</dl>

<h2 id="AbCall10">ab.call10</h2>

<p></p>
Returns <code><a href="#AColor">a.Color</a></code>
<dl>
<dt>JSON</dt>
<dd><code>
{}
</code></dd>
<dt>TL</dt>
<dd>
<code>read ab.call10#8db2a4f8 = a.Color;</code>
</dd>
</dl>

<h2 id="AbCall2">ab.call2</h2>

<p></p>
Expand Down
1 change: 1 addition & 0 deletions internal/tlcodegen/test/tls/goldmaster.tl
Original file line number Diff line number Diff line change
Expand Up @@ -263,5 +263,6 @@ service5Long.stringOutput#dc170ff5 http_code:long response:string = service5Long
@read ab.call7 x:typeA => ab.TypeB;
@read ab.call8 x:typeA => cd.TypeB;
@read ab.call9 x:typeA => TypeB;
@read ab.call10 => a.Color;

// @write logs2.addIndex type_id:int field:%String => Bool; // Test that %String is canonically resolved into primitive string
1 change: 1 addition & 0 deletions internal/tlcodegen/test/tls/goldmaster_canonical.tl
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ service5Long.stringOutput#dc170ff5 http_code:long response:string = service5Long
@read ab.call7#46ec10bf x:typeA = ab.TypeB // ./internal/tlcodegen/test/tls/goldmaster.tl
@read ab.call8#1b8652d9 x:typeA = cd.TypeB // ./internal/tlcodegen/test/tls/goldmaster.tl
@read ab.call9#75de906c x:typeA = TypeB // ./internal/tlcodegen/test/tls/goldmaster.tl
@read ab.call10#8db2a4f8 = a.Color // ./internal/tlcodegen/test/tls/goldmaster.tl
@read call1#a7302fbc x:ab.typeA = ab.TypeB // ./internal/tlcodegen/test/tls/goldmaster2.tl
@read call2#f02024c6 x:ab.typeA = cd.TypeB // ./internal/tlcodegen/test/tls/goldmaster2.tl
@read call3#6ace6718 x:ab.typeA = TypeB // ./internal/tlcodegen/test/tls/goldmaster2.tl
Expand Down

0 comments on commit 7da481e

Please sign in to comment.