diff --git a/R/old-0_1_1.R b/R/old-0_1_1.R new file mode 100644 index 00000000000..c4b73244f2f --- /dev/null +++ b/R/old-0_1_1.R @@ -0,0 +1,16 @@ +oldsample_0_1_1 <- function() { + list( + 3, + TRUE, + rep(c(0, 1, 2), each = 2L), + c(1, 2, 2, 0, 0, 1), + c(1, 0, 3, 2, 5, 4), + c(4, 3, 5, 0, 2, 1), + seq(0, 6, by = 2), + seq(0, 6, by = 2), + list(1, character(0), numeric(0)), + list(3, character(0), numeric(0)), + list(6, character(0), numeric(0)) + ) %>% + structure(class = "igraph") +} diff --git a/R/old-0_2.R b/R/old-0_2.R new file mode 100644 index 00000000000..eccdb823272 --- /dev/null +++ b/R/old-0_2.R @@ -0,0 +1,19 @@ +oldsample_0_2 <- function() { + list( + 3, + TRUE, + c(0, 1, 2), + c(1, 2, 0), + c(0, 1, 2), + c(2, 0, 1), + seq(0, 3, by = 1), + seq(0, 3, by = 1), + list( + c(1, 0), + list(), + list(bar = c("A", "B", "C")), + list(foo = c("a", "b", "c")) + ) + ) %>% + structure(class = "igraph") +} diff --git a/R/old-0_5.R b/R/old-0_5.R new file mode 100644 index 00000000000..b4330913eee --- /dev/null +++ b/R/old-0_5.R @@ -0,0 +1,20 @@ +oldsample_0_5 <- function() { + list( + 3, + TRUE, + c(0, 1, 2), + c(1, 2, 0), + c(0, 1, 2), + c(2, 0, 1), + seq(0, 3, by = 1), + seq(0, 3, by = 1), + list( + c(1, 0), + list() %>% + structure(names = character(0)), + list(bar = c("A", "B", "C")), + list(foo = c("a", "b", "c")) + ) + ) %>% + structure(class = "igraph") +} diff --git a/R/old-0_6.R b/R/old-0_6.R new file mode 100644 index 00000000000..2de9ee3ad21 --- /dev/null +++ b/R/old-0_6.R @@ -0,0 +1,19 @@ +oldsample_0_6 <- function() { + list( + 3, + TRUE, + c(0, 1, 2), + c(1, 2, 0), + c(0, 1, 2), + c(2, 0, 1), + seq(0, 3, by = 1), + seq(0, 3, by = 1), + list( + c(1, 0, 1), + list(name = "Ring graph", mutual = FALSE, circular = TRUE), + list(bar = c("A", "B", "C")), + list(foo = c("a", "b", "c")) + ) + ) %>% + structure(class = "igraph") +} diff --git a/R/old-1_0_0.R b/R/old-1_0_0.R new file mode 100644 index 00000000000..c7c92f7381d --- /dev/null +++ b/R/old-1_0_0.R @@ -0,0 +1,24 @@ +oldsample_1_0_0 <- function() { + ..env.1.. <- new.env(parent = baseenv()) + ..env.1..$me <- list( + 3, + TRUE, + c(0, 1, 2), + c(1, 2, 0), + c(0, 1, 2), + c(2, 0, 1), + seq(0, 3, by = 1), + seq(0, 3, by = 1), + list( + c(1, 0, 1), + list(name = "Ring graph", mutual = FALSE, circular = TRUE), + list(bar = c("A", "B", "C")), + list(foo = c("a", "b", "c")) + ), + ..env.1.. + ) %>% + structure(class = "igraph") + ..env.1..$.__igraph_version__. <- "0.8.0" + ..env.1..$myid <- "0fb28c05-9cc1-4a24-ba62-f5c319a3051b" + ..env.1..$me +} diff --git a/R/old-1_5_0.R b/R/old-1_5_0.R new file mode 100644 index 00000000000..fa296181204 --- /dev/null +++ b/R/old-1_5_0.R @@ -0,0 +1,28 @@ +oldsample_1_5_0 <- function() { + ..env.1.. <- new.env(parent = baseenv()) + ..env.1..$me <- list( + 3, + TRUE, + c(0, 1, 2), + c(1, 2, 0), + NULL, + NULL, + NULL, + NULL, + list( + c(1, 0, 1), + list(name = "Ring graph", mutual = FALSE, circular = TRUE), + list(bar = c("A", "B", "C")), + list(foo = c("a", "b", "c")) + ), + ..env.1.. + ) %>% + structure(class = "igraph") + + # This will be reconstructed on demand. + # ..env.1..$igraph <- constructive::.xptr("0x0") + + ..env.1..$.__igraph_version__. <- "1.5.0" + ..env.1..$myid <- "0fb28c05-9cc1-4a24-ba62-f5c319a3051b" + ..env.1..$me +} diff --git a/R/versions.R b/R/versions.R index 03f098a8d97..17090ae02ec 100644 --- a/R/versions.R +++ b/R/versions.R @@ -128,11 +128,24 @@ warn_version <- function(graph) { stop("This graph was created by a new(er) igraph version. Please install the latest version of igraph and try again.") } -oldformats <- function() { - readRDS(system.file("oldformats/oldformats.rds", package = "igraph")) +oldpredecessors <- function() { + c( + "1.5.0" = "1.4.3", + "1.0.0" = "0.7.1", + "0.6" = "0.5.5-4", + "0.5" = "0.4.5", + "0.2" = "0.1.2", + "0.1.1" = NA + ) } oldsamples <- function() { - f <- oldformats() - rlang::set_names(f$result, f$version) + list( + "1.5.0" = oldsample_1_5_0(), + "1.0.0" = oldsample_1_0_0(), + "0.6" = oldsample_0_6(), + "0.5" = oldsample_0_5(), + "0.2" = oldsample_0_2(), + "0.1.1" = oldsample_0_1_1() + ) } diff --git a/inst/oldformats/oldformats.rds b/inst/oldformats/oldformats.rds deleted file mode 100644 index 4b444a9e6b0..00000000000 Binary files a/inst/oldformats/oldformats.rds and /dev/null differ diff --git a/tests/testthat/_snaps/versions.md b/tests/testthat/_snaps/versions.md index 6e19ef7c503..09044316cbd 100644 --- a/tests/testthat/_snaps/versions.md +++ b/tests/testthat/_snaps/versions.md @@ -14,14 +14,6 @@ This graph was created by a now unsupported old igraph version. Call upgrade_version() before using igraph functions on that object. ---- - - Code - s[["0.4"]] - Error - This graph was created by a now unsupported old igraph version. - Call upgrade_version() before using igraph functions on that object. - --- Code @@ -43,10 +35,10 @@ Code s[["1.0.0"]] Output - IGRAPH U--- 3 3 -- Ring graph + IGRAPH D--- 3 3 -- Ring graph + attr: name (g/c), mutual (g/l), circular (g/l), bar (v/c), foo (e/c) - + edges from : - [1] 1--2 2--3 1--3 + + edges: + [1] 1->2 2->3 3->1 --- diff --git a/tests/testthat/test-versions.R b/tests/testthat/test-versions.R index 95e8ffb7c33..97b93212587 100644 --- a/tests/testthat/test-versions.R +++ b/tests/testthat/test-versions.R @@ -18,6 +18,8 @@ test_that("we can upgrade from 0.4.0 to 0.8.0", { }) test_that("reading of old igraph formats", { + local_igraph_options(print.id = FALSE) + s <- oldsamples() expect_snapshot(error = TRUE, { s[["0.1.1"]] @@ -25,9 +27,6 @@ test_that("reading of old igraph formats", { expect_snapshot(error = TRUE, { s[["0.2"]] }) - expect_snapshot(error = TRUE, { - s[["0.4"]] - }) expect_snapshot(error = TRUE, { s[["0.5"]] })