tests/testthat/references/calls.R

# ------------------------------------------------------------------------------
# subset

foo[bar]
foo[1, 2]
foo[1, ]
foo[1,, ]
foo[1,,2]
foo[x=1,,y=3,4]
foo[]

# ------------------------------------------------------------------------------
# subset2

foo[[x]]
foo[[x, y]]
foo[[x,]]
foo[[x,,]]
foo[[x,,y]]
foo[[]]

# ------------------------------------------------------------------------------
# subset and subset2 precedence

a[[b[1]]]
a[b[[1]]]

# ------------------------------------------------------------------------------
# switch

switch(foo,
  x = 1,
  "y" = 2,
  z = ,
  3
)

# ------------------------------------------------------------------------------
# calls

f()
f(x)
f(1+1)
f(1 ~ 1)
f(x, )
f(x,,y)
f(x, y)
f(x, y = 2)
f(x = 1 + 1)
f(x, y =)
f(f2(x, y))
f(,)
f(x,)
f(,y)
f(x=,)
f("x"=,)
f(... = ,)
f(,y=)

# ------------------------------------------------------------------------------
# braces

{}

{1}

{1; 2}

{1;
2}

{1
2
}

{
1
2
}

# https://github.com/r-lib/tree-sitter-r/issues/44
{
  1
2
  3
}

Try the treesitter.r package in your browser

Any scripts or data that you put into this service are public.

treesitter.r documentation built on Sept. 12, 2024, 7:06 a.m.