Skip to content

Commit 4ffb67c

Browse files
committed
Add specs from sass/sass-spec#2053
1 parent 988d9c7 commit 4ffb67c

File tree

2 files changed

+80
-0
lines changed

2 files changed

+80
-0
lines changed

spec/sass/value/function_spec.rb

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,4 +100,39 @@
100100
end
101101
end
102102
end
103+
104+
it 'rejects a compiler function from a different compilation' do
105+
plus_one = nil
106+
Sass.compile_string(
107+
"
108+
@use 'sass:meta';
109+
110+
@function plusOne($n) {@return $n + 1}
111+
a {b: meta.call(foo(meta.get-function('plusOne')), 2)}
112+
",
113+
functions: {
114+
'foo($arg)': ->(args) { plus_one = args[0] }
115+
}
116+
)
117+
118+
plus_two = nil
119+
expect do
120+
Sass.compile_string(
121+
"
122+
@use 'sass:meta';
123+
124+
@function plusTwo($n) {@return $n + 2}
125+
a {b: meta.call(foo(meta.get-function('plusTwo')), 2)}
126+
",
127+
functions: {
128+
'foo($arg)': lambda { |args|
129+
plus_two = args[0]
130+
plus_one
131+
}
132+
}
133+
)
134+
end.to raise_sass_compile_error.with_line(4)
135+
136+
expect(plus_one).not_to eq(plus_two)
137+
end
103138
end

spec/sass/value/mixin_spec.rb

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,49 @@
4545

4646
expect(fn).to have_received(:call)
4747
end
48+
49+
it 'rejects a compiler mixin from a different compilation' do
50+
a = nil
51+
Sass.compile_string(
52+
"
53+
@use 'sass:meta';
54+
55+
@mixin a() {
56+
a {
57+
b: c;
58+
}
59+
}
60+
61+
@include meta.apply(foo(meta.get-mixin('a')));
62+
",
63+
functions: {
64+
'foo($arg)': ->(args) { a = args[0] }
65+
}
66+
)
67+
68+
b = nil
69+
expect do
70+
Sass.compile_string(
71+
"
72+
@use 'sass:meta';
73+
74+
@mixin b() {
75+
c {
76+
d: e;
77+
}
78+
}
79+
80+
@include meta.apply(foo(meta.get-mixin('b')));
81+
",
82+
functions: {
83+
'foo($arg)': lambda { |args|
84+
b = args[0]
85+
a
86+
}
87+
}
88+
)
89+
end.to raise_sass_compile_error.with_line(9)
90+
91+
expect(a).not_to eq(b)
92+
end
4893
end

0 commit comments

Comments
 (0)