Skip to content

Commit 412995f

Browse files
committed
adding more rlang tests to match pre-existing lua and python ones
Signed-off-by: Elijah Cúchulainn Reid <[email protected]>
1 parent a3be20b commit 412995f

File tree

3 files changed

+75
-0
lines changed

3 files changed

+75
-0
lines changed

client/test/components/util/SASCodeDocument.test.ts

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,40 @@ run;
3838
assert.equal(sasCodeDoc.getWrappedCode(), expected);
3939
});
4040

41+
it("wrap rlang code", () => {
42+
const parameters: SASCodeDocumentParameters = {
43+
languageId: "rlang",
44+
code: `for (x in 1:6) {
45+
print(x)
46+
}
47+
print("test")`,
48+
selectedCode: "",
49+
htmlStyle: "Illuminate",
50+
outputHtml: true,
51+
uuid: "519058ad-d33b-4b5c-9d23-4cc8d6ffb163",
52+
checkKeyword: async () => false,
53+
};
54+
55+
const sasCodeDoc = new SASCodeDocument(parameters);
56+
57+
const expected = `/** LOG_START_INDICATOR **/
58+
title;footnote;ods _all_ close;
59+
ods graphics on;
60+
ods html5(id=vscode) style=Illuminate options(bitmap_mode='inline' svg_mode='inline') body="519058ad-d33b-4b5c-9d23-4cc8d6ffb163.htm";
61+
proc rlang;
62+
submit;
63+
for (x in 1:6) {
64+
print(x)
65+
}
66+
print("test")
67+
endsubmit;
68+
run;
69+
;*';*";*/;run;quit;ods html5(id=vscode) close;
70+
`;
71+
72+
assert.equal(sasCodeDoc.getWrappedCode(), expected);
73+
});
74+
4175
it("wrap sql code", () => {
4276
const parameters: SASCodeDocumentParameters = {
4377
languageId: "sql",

client/testFixture/formatter/expected.sas

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,16 @@ def my_function():
4646
endsubmit;
4747
run;
4848

49+
proc rlang;
50+
submit;
51+
# Reference to variable defined in previous PROC RLANG call
52+
print(paste("x =", x))
53+
my_function <- function() {
54+
print("Inside the proc step")
55+
}
56+
endsubmit;
57+
run;
58+
4959
proc lua;
5060
submit;
5161
local dsid = sas.open("sashelp.company") -- open for input
@@ -131,6 +141,17 @@ print('first statement after for loop')
131141
endinteractive;
132142
run;
133143

144+
proc rlang;
145+
submit;
146+
fruits <- c("apple", "banana", "cherry")
147+
for (x in fruits) {
148+
print(x)
149+
}
150+
151+
print('first statement after for loop')
152+
endsubmit;
153+
run;
154+
134155
proc lua;
135156
submit;
136157

client/testFixture/formatter/unformatted.sas

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,15 @@ def my_function():
4040
print("Inside the proc step")
4141
endsubmit;
4242
run;
43+
proc rlang;
44+
submit;
45+
# Reference to variable defined in previous PROC RLANG call
46+
print(paste("x =", x))
47+
my_function <- function() {
48+
print("Inside the proc step")
49+
}
50+
endsubmit;
51+
run;
4352
proc lua;
4453
submit;
4554
local dsid = sas.open("sashelp.company") -- open for input
@@ -126,6 +135,17 @@ print('first statement after for loop')
126135
endinteractive;
127136
run;
128137

138+
proc rlang;
139+
submit;
140+
fruits <- c("apple", "banana", "cherry")
141+
for (x in fruits) {
142+
print(x)
143+
}
144+
145+
print('first statement after for loop')
146+
endsubmit;
147+
run;
148+
129149
proc lua;
130150
submit;
131151

0 commit comments

Comments
 (0)