-
-
Notifications
You must be signed in to change notification settings - Fork 8
Fixes integer shorthand regression #227
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
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
06289d0
fix: regression and adds test
averissimo 9695f84
Merge branch 'main' into integer_shorthand_regression@211_subset@main
gogonzo f361e6c
@llrs-roche review
gogonzo 3fd5e5a
add to eval_code docs
gogonzo 8e9bf13
more clear code
gogonzo e9b4b71
@llrs-roche review
gogonzo 90f181e
remove unnecessary
gogonzo 314a829
- simplify Reduce call
gogonzo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or 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,13 +1,13 @@ | ||
| testthat::test_that("eval_code evaluates the code in the qenvs environment", { | ||
| q <- qenv() | ||
| q1 <- eval_code(q, quote(iris1 <- iris)) | ||
| q2 <- eval_code(q1, quote(b <- nrow(iris1))) | ||
| testthat::expect_identical(q2$b, 150L) | ||
| q1 <- eval_code(q, quote(a <- 1L)) | ||
| q2 <- eval_code(q1, quote(b <- 1)) | ||
| testthat::expect_equal(q2, list2env(list(a = 1L, b = 1))) | ||
| }) | ||
|
|
||
| testthat::test_that("eval_code locks the environment", { | ||
| q <- eval_code(qenv(), quote(iris1 <- iris)) | ||
| testthat::expect_true(environmentIsLocked(q@.xData)) | ||
| testthat::expect_true(environmentIsLocked(q)) | ||
| }) | ||
|
|
||
| testthat::test_that("eval_code doesn't have access to environment where it's called", { | ||
|
|
@@ -36,21 +36,29 @@ testthat::test_that("getting object from the package namespace works even if lib | |
| testthat::test_that("eval_code works with character", { | ||
| q1 <- eval_code(qenv(), "a <- 1") | ||
| testthat::expect_identical(get_code(q1), "a <- 1") | ||
| testthat::expect_equal(q1@.xData, list2env(list(a = 1))) | ||
| testthat::expect_equal(q1, list2env(list(a = 1))) | ||
| }) | ||
|
|
||
| testthat::test_that("eval_code works with expression", { | ||
| q1 <- eval_code(qenv(), as.expression(quote(a <- 1))) | ||
| q1 <- eval_code(qenv(), expression(a <- 1, b <- 2)) | ||
| testthat::expect_identical(get_code(q1), "a <- 1\nb <- 2") | ||
| testthat::expect_equal(q1, list2env(list(a = 1, b = 2))) | ||
| }) | ||
|
|
||
| testthat::expect_identical(get_code(q1), "a <- 1") | ||
| testthat::expect_equal([email protected], list2env(list(a = 1))) | ||
| testthat::test_that("eval_code preserves original formatting when `srcref` is present in the expression", { | ||
| code <- "# comment | ||
| a <- 1L" | ||
| expr <- parse(text = code, keep.source = TRUE) | ||
| q1 <- eval_code(qenv(), expr) | ||
| testthat::expect_identical(get_code(q1), code) | ||
| testthat::expect_equal(q1, list2env(list(a = 1L))) | ||
| }) | ||
|
|
||
| testthat::test_that("eval_code works with quoted", { | ||
| q1 <- eval_code(qenv(), quote(a <- 1)) | ||
|
|
||
| testthat::expect_identical(get_code(q1), "a <- 1") | ||
| testthat::expect_equal(q1@.xData, list2env(list(a = 1))) | ||
| testthat::expect_equal(q1, list2env(list(a = 1))) | ||
| }) | ||
|
|
||
| testthat::test_that("eval_code works with quoted code block", { | ||
|
|
@@ -66,7 +74,7 @@ testthat::test_that("eval_code works with quoted code block", { | |
| get_code(q1), | ||
| c("a <- 1\nb <- 2") | ||
| ) | ||
| testthat::expect_equal(q1@.xData, list2env(list(a = 1, b = 2))) | ||
| testthat::expect_equal(q1, list2env(list(a = 1, b = 2))) | ||
| }) | ||
|
|
||
| testthat::test_that("eval_code fails with unquoted expression", { | ||
|
|
@@ -172,3 +180,8 @@ testthat::test_that("comments passed alone to eval_code that contain @linksto ta | |
| "x" | ||
| ) | ||
| }) | ||
|
|
||
| testthat::test_that("Code executed with integer shorthand (1L) is the same as original", { | ||
| q <- within(qenv(), a <- 1L) | ||
| testthat::expect_identical(get_code(q), "a <- 1L") | ||
| }) | ||
llrs-roche marked this conversation as resolved.
Show resolved
Hide resolved
|
||
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -64,10 +64,17 @@ testthat::test_that("styling of input code does not impact evaluation results", | |
|
|
||
|
|
||
| # return value ---- | ||
| testthat::test_that("within.qenv renturns a `qenv` where `@.xData` is a deep copy of that in `data`", { | ||
| testthat::test_that("within.qenv empty call doesn't change qenv object", { | ||
| q <- qenv() | ||
| q <- within(qenv(), i <- iris) | ||
| qq <- within(q, {}) | ||
| testthat::expect_identical(q, qq) | ||
| }) | ||
|
|
||
| testthat::test_that("within.qenv renturns a `qenv` where `@.xData` is a deep copy of that in `data`", { | ||
| q <- qenv() | ||
| q <- within(qenv(), i <- iris) | ||
| qq <- within(q, i) | ||
| testthat::expect_equal([email protected], [email protected]) | ||
| testthat::expect_false(identical([email protected], [email protected])) | ||
| }) | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.