insightsengineering / insightsengineering/teal.code
[Feature Request]: Support code dependency on a single expression with multiple assignments
- Dominant language
- R
- Stars
- 12
- Forks
- 11
- Avg merge
- 1d 17h
- Merged PRs (30d)
- 1
Description
### Feature description
Such as `var1 <- var2 <- 2`
``` r
pkgload::load_all("../teal.code")
#> ℹ Loading teal.code
code <- "var1 <- var2 <- 1"
td <- eval_code(qenv(), code)
get_code(td, names = "var1")
#> [1] "var1 <- var2 <- 1"
get_code(td, names = "var2")
#> Warning: Object(s) not found in code: var2.
#> [1] ""
```
Created on 2025-04-30 with [reprex v2.1.1](https://reprex.tidyverse.org)
See test suite below for test-driven development
```r
testthat::describe("detects multiple assignments in single line", {
testthat::it("<-", {
# testthat::skip("Not implemented")
code <- "var1 <- var2 <- 1"
td <- eval_code(qenv(), code)
testthat::expect_identical(get_code(td, names = "var1"), code)
testthat::expect_identical(get_code(td, names = "var2"), code)
})
testthat::it("->", {
code <- "1 -> var1 -> var2"
td <- eval_code(qenv(), code)
testthat::expect_identical(
get_code(td, names = "var1"),
as.character(parse(text = code, keep.source = TRUE))
)
testthat::expect_identical(get_code(td, names = "var1"), code)
testthat::expect_identical(get_code(td, names = "var2"), code)
})
testthat::it("<- and ->", {
code <- "var1 <- 1 -> var2"
td <- eval_code(qenv(), code)
testthat::expect_identical(get_code(td, names = "var1"), code)
testthat::expect_identical(get_code(td, names = "var2"), code)
})
})
```
### Code of Conduct
- [x] I agree to follow this project's Code of Conduct.
### Contribution Guidelines
- [x] I agree to follow this project's Contribution Guidelines.
### Security Policy
- [x] I agree to follow this project's Security Policy.
Contributor guide
Assessment
This issue has not been assessed yet.