-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(R): Fix checking of property types
Also removes unused functions
- Loading branch information
Showing
3 changed files
with
73 additions
and
77 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 |
---|---|---|
@@ -1,15 +1,80 @@ | ||
context("types") | ||
|
||
test_that("Entity", { | ||
test_that("core typing functions work", { | ||
expect_equal(last_class(Entity()), "Entity") | ||
expect_true(inherits(Entity(), "Entity")) | ||
}) | ||
|
||
test_that("Person", { | ||
test_that("can construct a simple node", { | ||
jane <- Person( | ||
honorificPrefix = "Dr", | ||
givenNames = c("Jane"), | ||
familyNames = list("Jones", "Jamieson") | ||
) | ||
expect_equal(jane$familyNames, c("Jones", "Jamieson")) | ||
}) | ||
|
||
test_that("arguments to constructor functions are checked", { | ||
expect_error( | ||
Datatable(), | ||
"Datatable\\$columns is required" | ||
) | ||
|
||
expect_error( | ||
Datatable( | ||
columns = list( | ||
Person() | ||
) | ||
), | ||
"Datatable\\$columns is type list, expected type Array\\(DatatableColumn\\)" | ||
) | ||
|
||
expect_error( | ||
Datatable( | ||
columns = list( | ||
DatatableColumn( | ||
name = "A" | ||
) | ||
) | ||
), | ||
"DatatableColumn\\$values is required" | ||
) | ||
|
||
expect_error( | ||
Datatable( | ||
columns = list( | ||
DatatableColumn( | ||
name = "A", | ||
values = matrix() | ||
) | ||
) | ||
), | ||
"DatatableColumn\\$values is type matrix, expected type Array\\(Any\\(\\)\\)" | ||
) | ||
|
||
expect_error( | ||
Datatable( | ||
columns = list( | ||
DatatableColumn( | ||
name = "A", | ||
values = 1, | ||
validator = NumberValidator() | ||
) | ||
) | ||
), | ||
"DatatableColumn\\$validator is type NumberValidator, expected type ArrayValidator$" | ||
) | ||
|
||
expect_equal( | ||
Datatable( | ||
columns = list( | ||
DatatableColumn( | ||
name = "A", | ||
values = 1:10, | ||
validator = ArrayValidator(items = NumberValidator()) | ||
) | ||
) | ||
)$columns[[1]]$values, | ||
1:10 | ||
) | ||
}) |
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