test_that("V8 prettify JavaScript with default `tabSize`", {
skip_if_not_installed("V8")
skip_if(substr(V8::engine_info()$version, 1 , 1) < 6, "V8 engine too old.")
code <- c(
"function f(x){",
"var y= x+1",
"console.log('y:',y) ;",
"}"
)
prettyCode <- prettify_V8(code, "javascript")
expect_equal(
prettyCode,
"function f(x) {\n var y = x + 1;\n console.log(\"y:\", y);\n}\n"
)
})
test_that("V8 prettify JavaScript with given `tabSize`", {
skip_if_not_installed("V8")
skip_if(substr(V8::engine_info()$version, 1 , 1) < 6, "V8 engine too old.")
code <- c(
"function f(x){",
"var y= x+1",
"console.log('y:',y) ;",
"}"
)
prettyCode <- prettify_V8(code, "javascript", tabSize = 4)
expect_equal(
prettyCode,
"function f(x) {\n var y = x + 1;\n console.log(\"y:\", y);\n}\n"
)
})
test_that("V8 reindent JavaScript with default `tabSize`", {
skip_if_not_installed("V8")
skip_if(substr(V8::engine_info()$version, 1 , 1) < 6, "V8 engine too old.")
code <- c(
"function f(x){",
"var y= x+1",
"console.log('y:',y) ;",
"}"
)
prettyCode <- reindent_V8(code, "javascript")
expect_equal(
prettyCode,
"function f(x){\r\n var y= x+1\r\n console.log('y:',y) ;\r\n}"
)
})
test_that("V8 reindent JavaScript with given `tabSize`", {
skip_if_not_installed("V8")
skip_if(substr(V8::engine_info()$version, 1 , 1) < 6, "V8 engine too old.")
code <- c(
"function f(x){",
"var y= x+1",
"console.log('y:',y) ;",
"}"
)
prettyCode <- reindent_V8(code, "javascript", tabSize = 4)
expect_equal(
prettyCode,
"function f(x){\r\n var y= x+1\r\n console.log('y:',y) ;\r\n}"
)
})
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.