Skip to content

Commit

Permalink
Uncommented broken mangling specs
Browse files Browse the repository at this point in the history
  • Loading branch information
khaitu committed Nov 27, 2023
1 parent 49df385 commit 21c41bd
Showing 1 changed file with 41 additions and 42 deletions.
83 changes: 41 additions & 42 deletions spec/terser_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,48 +46,47 @@
expect(Terser.new.compile('var foo="\0bar"')).to include("\\0bar")
end

# TODO: fixme
# describe "property name mangling" do
# let(:source) do
# <<-JS
# var obj = {
# _hidden: false,
# "quoted": 'value'
# };
#
# alert(object.quoted);
# JS
# end
#
# it "does not mangle property names by default" do
# expect(Terser.compile(source)).to include("object.quoted")
# end
#
# it "can be configured to mangle properties" do
# expect(Terser.compile(source, :mangle => { :properties => true }))
# .not_to include("object.quoted")
# end
#
# it "can be configured using old mangle_properties" do
# expect(Terser.compile(source, :mangle_properties => true))
# .not_to include("object.quoted")
# end
#
# it "can configure a regex for mangling" do
# expect(Terser.compile(source, :mangle => { :properties => { :regex => /^_/ } }))
# .to include("object.quoted")
# end
#
# it "can be configured to keep quoted properties" do
# expect(Terser.compile(source, :mangle => { :properties => { :keep_quoted => true } }))
# .to include("object.quoted")
# end
#
# it "can be configured to include debug in mangled properties" do
# expect(Terser.compile(source, :mangle => { :properties => { :debug => true } }))
# .to include("_$quoted$_")
# end
# end
describe "property name mangling" do
let(:source) do
<<-JS
var obj = {
_hidden: false,
"quoted": 'value'
};
alert(object.quoted);
JS
end

it "does not mangle property names by default" do
expect(Terser.compile(source)).to include("object.quoted")
end

it "can be configured to mangle properties" do
expect(Terser.compile(source, :mangle => { :properties => true }))
.not_to include("object.quoted")
end

it "can be configured using old mangle_properties" do
expect(Terser.compile(source, :mangle_properties => true))
.not_to include("object.quoted")
end

it "can configure a regex for mangling" do
expect(Terser.compile(source, :mangle => { :properties => { :regex => /^_/ } }))
.to include("object.quoted")
end

it "can be configured to keep quoted properties" do
expect(Terser.compile(source, :mangle => { :properties => { :keep_quoted => true } }))
.to include("object.quoted")
end

it "can be configured to include debug in mangled properties" do
expect(Terser.compile(source, :mangle => { :properties => { :debug => true } }))
.to include("_$quoted$_")
end
end

describe "argument name mangling" do
let(:code) { "function bar(foo) {return foo + 'bar'};" }
Expand Down

0 comments on commit 21c41bd

Please sign in to comment.