From 21c41bd054741fa76b49c3248285ab84e87be6cf Mon Sep 17 00:00:00 2001 From: Tom Chislett Date: Mon, 27 Nov 2023 10:43:53 -0600 Subject: [PATCH] Uncommented broken mangling specs --- spec/terser_spec.rb | 83 ++++++++++++++++++++++----------------------- 1 file changed, 41 insertions(+), 42 deletions(-) diff --git a/spec/terser_spec.rb b/spec/terser_spec.rb index 94c821a..1274c67 100644 --- a/spec/terser_spec.rb +++ b/spec/terser_spec.rb @@ -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'};" }