tests/testthat/test.lex_error4.R

#! /usr/bin/env Rscript

library(testthat)
library(rly)

context("t_error defined as function, but too many args")

Lexer <- R6::R6Class("Lexer",
  public = list(
    tokens = c('NUMBER', 'PLUS','MINUS'),
    t_PLUS = '\\+',
    t_MINUS = '-',
    t_NUMBER = '\\d+',
    t_error = function(t, s) {}
  )
)

test_that("t_error too many arg", {
  expect_output(expect_error(rly::lex(Lexer), "Can't build lexer"),
  "ERROR .* Rule error has too many arguments")
})

Try the rly package in your browser

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

rly documentation built on May 8, 2022, 5:05 p.m.