-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from systemincloud/issue_3
#3 Handling circular type definitions
- Loading branch information
Showing
3 changed files
with
222 additions
and
31 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
service PingPong { | ||
Foo echo(1:Foo param) | ||
} | ||
|
||
struct Foo { | ||
1: optional Bar test, | ||
2: optional SomeInt some_int, | ||
} | ||
|
||
struct Bar { | ||
1: optional Foo test, | ||
} | ||
|
||
const SomeInt SOME_INT = [1, 2, 3] | ||
|
||
typedef list<i32> SomeInt |
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,28 @@ | ||
#! /usr/bin/env Rscript | ||
|
||
library(testthat) | ||
|
||
context("recursive_definition") | ||
|
||
test_that("test_recursive_definition", { | ||
thrift <- thriftr::t_load("recursive_definition.thrift") | ||
expect_equal(thrift$Bar$thrift_spec[["1"]][[1]], 12) | ||
expect_equal(thrift$Bar$thrift_spec[["1"]][[2]], "test") | ||
expect_equal(thrift$Bar$thrift_spec[["1"]][[3]], thrift$Foo) | ||
expect_equal(thrift$Bar$thrift_spec[["1"]][[4]], FALSE) | ||
expect_equal(thrift$Foo$thrift_spec[["1"]][[1]], 12) | ||
expect_equal(thrift$Foo$thrift_spec[["1"]][[2]], 'test') | ||
expect_equal(thrift$Foo$thrift_spec[["1"]][[3]], thrift$Bar) | ||
expect_equal(thrift$Foo$thrift_spec[["1"]][[4]], FALSE) | ||
expect_equal(thrift$Foo$thrift_spec[["2"]][[1]], 15) | ||
expect_equal(thrift$Foo$thrift_spec[["2"]][[2]], 'some_int') | ||
expect_equal(thrift$Foo$thrift_spec[["2"]][[3]], 8) | ||
expect_equal(thrift$Foo$thrift_spec[["2"]][[4]], FALSE) | ||
}) | ||
|
||
test_that("test_const", { | ||
thrift <- thriftr::t_load("recursive_definition.thrift") | ||
expect_equal(thrift$SOME_INT[[1]], 1) | ||
expect_equal(thrift$SOME_INT[[2]], 2) | ||
expect_equal(thrift$SOME_INT[[3]], 3) | ||
}) |