From c34fa4172f1c0f6ab42e661b1b201fbfd628457c Mon Sep 17 00:00:00 2001 From: JohnnyMorganz Date: Sat, 11 Nov 2023 14:41:05 +0100 Subject: [PATCH] Cleanup clippy warnings --- tests/test_call_parentheses.rs | 56 +++++++++++++++++----------------- tests/test_no_call_parens.rs | 24 +++++++-------- tests/test_quote_style.rs | 16 +++++----- tests/test_ranges.rs | 12 ++++---- tests/tests.rs | 4 +-- 5 files changed, 56 insertions(+), 56 deletions(-) diff --git a/tests/test_call_parentheses.rs b/tests/test_call_parentheses.rs index 7f826220..125dda44 100644 --- a/tests/test_call_parentheses.rs +++ b/tests/test_call_parentheses.rs @@ -14,7 +14,7 @@ fn format(paren_type: CallParenType, input: &str) -> String { fn test_call_parens_always_handles_string_correctly() { insta::assert_snapshot!( format(CallParenType::Always, - r###" + r#" local foo = require "foo" local has_parens = require("configuration").has_parens @@ -24,7 +24,7 @@ multi line string ]] -"### +"# ), @r###" local foo = require("foo") @@ -44,7 +44,7 @@ string fn test_call_parens_always_handles_table_correctly() { insta::assert_snapshot!( format(CallParenType::Always, - r###" + r#" local opt = my_function { hello = true, } @@ -53,7 +53,7 @@ local still_got_em = my_function({ config = true, value = "yup", }):method() -"### +"# ), @r###" local opt = my_function({ @@ -72,7 +72,7 @@ local still_got_em = my_function({ fn test_call_parens_no_single_string_handles_string_correctly() { insta::assert_snapshot!( format(CallParenType::NoSingleString, - r###" + r#" local foo = require "foo" local has_parens = require("configuration").has_parens @@ -82,7 +82,7 @@ multi line string ]] -"### +"# ), @r###" local foo = require "foo" @@ -102,7 +102,7 @@ string fn test_call_parens_no_single_string_handles_table_correctly() { insta::assert_snapshot!( format(CallParenType::NoSingleString, - r###" + r#" local opt = my_function { hello = true, } @@ -111,7 +111,7 @@ local still_got_em = my_function({ config = true, value = "yup", }):method() -"### +"# ), @r###" local opt = my_function({ @@ -130,7 +130,7 @@ local still_got_em = my_function({ fn test_call_parens_no_single_table_handles_string_correctly() { insta::assert_snapshot!( format(CallParenType::NoSingleTable, - r###" + r#" local foo = require "foo" local has_parens = require("configuration").has_parens @@ -140,7 +140,7 @@ multi line string ]] -"### +"# ), @r###" local foo = require("foo") @@ -160,7 +160,7 @@ string fn test_call_parens_no_single_table_handles_table_correctly() { insta::assert_snapshot!( format(CallParenType::NoSingleTable, - r###" + r#" local opt = my_function { hello = true, } @@ -169,7 +169,7 @@ local still_got_em = my_function({ config = true, value = "yup", }):method() -"### +"# ), @r###" local opt = my_function { @@ -188,7 +188,7 @@ local still_got_em = my_function({ fn test_call_parens_none_handles_string_correctly() { insta::assert_snapshot!( format(CallParenType::None, - r###" + r#" local foo = require "foo" local has_parens = require("configuration").has_parens @@ -198,7 +198,7 @@ multi line string ]] -"### +"# ), @r###" local foo = require "foo" @@ -218,7 +218,7 @@ string fn test_call_parens_none_handles_table_correctly() { insta::assert_snapshot!( format(CallParenType::None, - r###" + r#" local opt = my_function { hello = true, } @@ -227,7 +227,7 @@ local still_got_em = my_function({ config = true, value = "yup", }):method() -"### +"# ), @r###" local opt = my_function { @@ -246,11 +246,11 @@ local still_got_em = my_function({ fn test_call_parens_has_no_affect_on_multi_arg_fn_calls_() { insta::assert_snapshot!( format(CallParenType::Always, - r###" + r#" local opt = my_function({ hello = true, }, "strarg", 5) -"### +"# ), @r###" local opt = my_function({ @@ -260,11 +260,11 @@ local opt = my_function({ ); insta::assert_snapshot!( format(CallParenType::NoSingleTable, - r###" + r#" local opt = my_function({ hello = true, }, "strarg", 5) -"### +"# ), @r###" local opt = my_function({ @@ -274,11 +274,11 @@ local opt = my_function({ ); insta::assert_snapshot!( format(CallParenType::None, - r###" + r#" local opt = my_function({ hello = true, }, "strarg", 5) -"### +"# ), @r###" local opt = my_function({ @@ -292,9 +292,9 @@ local opt = my_function({ fn test_call_parens_comments() { insta::assert_snapshot!( format(CallParenType::None, - r###" + r#" foo("hello") -- comment -"### +"# ), @r###"foo "hello" -- comment "### @@ -305,10 +305,10 @@ foo("hello") -- comment fn test_call_parens_semicolons() { insta::assert_snapshot!( format(CallParenType::None, - r###" + r#" foo"hello"; -- comment foo{ x = y }; -- comment -"### +"# ), @r###" foo "hello" -- comment @@ -321,12 +321,12 @@ foo{ x = y }; -- comment fn test_call_parens_input() { insta::assert_snapshot!( format(CallParenType::Input, - r###" + r#" require("path") local x = New "TextLabel" { x = game:FindFirstChild("Testing") } -"### +"# ), @r###" require("path") diff --git a/tests/test_no_call_parens.rs b/tests/test_no_call_parens.rs index 12f5a8ad..34dc2203 100644 --- a/tests/test_no_call_parens.rs +++ b/tests/test_no_call_parens.rs @@ -14,9 +14,9 @@ fn format(input: &str) -> String { fn test_no_parens_string() { insta::assert_snapshot!( format( - r###" + r#" foo"string" -"### +"# ), @r###"foo "string" "### @@ -27,9 +27,9 @@ foo"string" fn test_omit_parens_string() { insta::assert_snapshot!( format( - r###" + r#" foo("string") -"### +"# ), @r###"foo "string" "### @@ -107,9 +107,9 @@ foo{ fn test_keep_parens_binop_string() { insta::assert_snapshot!( format( - r###" + r#" foo("foo" .. "bar") -"### +"# ), @r###"foo("foo" .. "bar") "### @@ -120,9 +120,9 @@ foo("foo" .. "bar") fn test_no_parens_method_chain_1() { insta::assert_snapshot!( format( - r###" + r#" foo("foo"):andThen() -"### +"# ), @r###"foo("foo"):andThen() "### @@ -133,11 +133,11 @@ foo("foo"):andThen() fn test_no_parens_method_chain_2() { insta::assert_snapshot!( format( - r###" + r#" Job:new({ foo = "bar" }):sync() -"### +"# ), @r###" Job:new({ @@ -151,7 +151,7 @@ Job:new({ fn test_no_parens_large_example() { insta::assert_snapshot!( format( - r###" + r#" local foo = require "foo" local has_parens = require("configuration").has_parens @@ -163,7 +163,7 @@ local still_got_em = my_function({ config = true, value = "yup", }):method() -"### +"# ), @r###" local foo = require "foo" diff --git a/tests/test_quote_style.rs b/tests/test_quote_style.rs index 290d8a55..95259cd6 100644 --- a/tests/test_quote_style.rs +++ b/tests/test_quote_style.rs @@ -14,7 +14,7 @@ fn format(input: &str, quote_style: QuoteStyle) -> String { fn test_auto_prefer_double_quotes() { insta::assert_snapshot!( format( - r###" + r#" local a = "foobar" local c = 'foobar' local d = "foo\"bar" @@ -23,7 +23,7 @@ local f = "foo'bar" local g = 'foo\'bar' local h = "foo\"bar'baz" local i = 'foo"bar\'baz' - "###, + "#, QuoteStyle::AutoPreferDouble ), @r###" @@ -43,7 +43,7 @@ local i = 'foo"bar\'baz' fn test_auto_prefer_single_quotes() { insta::assert_snapshot!( format( - r###" + r#" local a = "foobar" local c = 'foobar' local d = "foo\"bar" @@ -52,7 +52,7 @@ local f = "foo'bar" local g = 'foo\'bar' local h = "foo\"bar'baz" local i = 'foo"bar\'baz' - "###, + "#, QuoteStyle::AutoPreferSingle ), @r###" @@ -72,7 +72,7 @@ local i = 'foo"bar\'baz' fn test_force_double_quotes() { insta::assert_snapshot!( format( - r###" + r#" local a = "foobar" local c = 'foobar' local d = "foo\"bar" @@ -81,7 +81,7 @@ local f = "foo'bar" local g = 'foo\'bar' local h = "foo\"bar'baz" local i = 'foo"bar\'baz' - "###, + "#, QuoteStyle::ForceDouble ), @r###" @@ -101,7 +101,7 @@ local i = 'foo"bar\'baz' fn test_force_single_quotes() { insta::assert_snapshot!( format( - r###" + r#" local a = "foobar" local c = 'foobar' local d = "foo\"bar" @@ -110,7 +110,7 @@ local f = "foo'bar" local g = 'foo\'bar' local h = "foo\"bar'baz" local i = 'foo"bar\'baz' - "###, + "#, QuoteStyle::ForceSingle ), @r###" diff --git a/tests/test_ranges.rs b/tests/test_ranges.rs index d3812b6f..3fece4e3 100644 --- a/tests/test_ranges.rs +++ b/tests/test_ranges.rs @@ -95,7 +95,7 @@ fn test_incomplete_range() { fn test_large_example() { insta::assert_snapshot!( format( - r###"||if string.sub(msg, 1, 8) == "setgrav/" then + r#"||if string.sub(msg, 1, 8) == "setgrav/" then danumber = nil for i = 9, 100 do if string.sub(msg, i, i) == "/" then danumber = i break end end if danumber == nil then return end local player = findplayer(string.sub(msg, 9, danumber - 1), speaker) if player == 0 then return end for i = 1, #player do if player[i].Character ~= nil then @@ -116,7 +116,7 @@ if player[i].Character ~= nil then local torso = player[i].Character:FindFirstChild("Torso") if torso ~= nil then torso.CFrame = CFrame.new(torso.Position.x, torso.Position.y, torso.Position.z, 0, 0, 1, 0, -1, 0, 1, 0, 0) --math.random(),math.random(),math.random(),math.random(),math.random(),math.random(),math.random(),math.random(),math.random()) -- i like the people being upside down better. end end end end end - "### + "# ), @r###" @@ -174,10 +174,10 @@ end end end end end fn test_nested_range() { insta::assert_snapshot!( format( - r###"local my_function = function() + r#"local my_function = function() ||local nested_statement = "foobar"|| end -"### +"# ), @r###" @@ -191,12 +191,12 @@ end fn test_nested_range_local_function() { insta::assert_snapshot!( format( - r###"local function test() + r#"local function test() call "hello" ||call { x = y} local z = 1 + 3 - (2 / 3)|| end -"### +"# ), @r###" local function test() diff --git a/tests/tests.rs b/tests/tests.rs index 03eda6c3..9fc11f0e 100644 --- a/tests/tests.rs +++ b/tests/tests.rs @@ -131,7 +131,7 @@ fn test_sort_requires() { #[test] fn test_crlf_in_multiline_comments() { // We need to do this outside of insta since it normalises line endings to LF - let code = r###" + let code = r#" local a = "testing" --[[ This comment @@ -140,7 +140,7 @@ local a = "testing" convert to CRLF ]] local x = 1 -"###; +"#; let code_crlf = code.lines().collect::>().join("\r\n"); let output = format(&code_crlf);