~gabor.csardi/igraph/develop

« back to all changes in this revision

Viewing changes to interfaces/R/igraph/inst/tests/test_iterators.R

  • Committer: Gabor Csardi
  • Date: 2013-11-14 04:18:22 UTC
  • Revision ID: git-v1:a24be1aa65db8e8a8e37eb382e45d996aec2f35b
R: better handling of complex attributes, [[ on v/e sets, fixes #231.

It would be nice to document it properly, but let's wait
to see if it makes sense, at all.

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
  ## TODO: %--%, %->%, other special functions
17
17
 
18
18
})
 
19
 
 
20
test_that("complex attributes work", {
 
21
  library(igraph)
 
22
 
 
23
  g <- graph.ring(10)
 
24
  foo <- lapply(1:vcount(g), seq, from=1)
 
25
  V(g)$foo <- foo
 
26
 
 
27
  V(g)$foo[[5]][1:3] <- 0
 
28
  expect_that(V(g)[(1:10)[-5]]$foo, equals(foo[-5]))
 
29
  expect_that(V(g)[[5]]$foo, equals(c(0,0,0,4,5)))
 
30
  expect_that(V(g)[5]$foo, equals(list(c(0,0,0,4,5))))
 
31
 
 
32
  V(g)$foo <- foo
 
33
  V(g)[[5]]$foo[1:3] <- 0
 
34
  expect_that(V(g)[(1:10)[-5]]$foo, equals(foo[-5]))
 
35
  expect_that(V(g)[[5]]$foo, equals(c(0,0,0,4,5)))
 
36
  expect_that(V(g)[5]$foo, equals(list(c(0,0,0,4,5))))
 
37
 
 
38
  V(g)$foo <- foo
 
39
  V(g)[5]$foo[[1]][1:3] <- 0
 
40
  expect_that(V(g)[(1:10)[-5]]$foo, equals(foo[-5]))
 
41
  expect_that(V(g)[[5]]$foo, equals(c(0,0,0,4,5)))
 
42
  expect_that(V(g)[5]$foo, equals(list(c(0,0,0,4,5))))
 
43
 
 
44
})