<commit_before>require 'test/unit'
require 'jsshuffle'
require 'execjs'

class ParameterRenamingTest < Test::Unit::TestCase
    def test_can_include
        assert_nothing_raised do
            @shuffler = JsShuffle::Shuffler.new use: :parameter_renaming
        end
    end

    def test_name_changes
        assert_nothing_raised do @shuffler = JsShuffle::Shuffler.new use: :parameter_renaming end
        original = %Q(
            function double(parameter) {
                return parameter*2;
            }
        )
        assert_not_equal original,
            @shuffler.shuffle( js: original )
    end

    def test_code_works
        assert_nothing_raised do @shuffler = JsShuffle::Shuffler.new use: :parameter_renaming end
        shuffled = @shuffler.shuffle js: %Q(
            function double(parameter) {
                return parameter*2;
            }
            return double(333);
        )
        assert_equal 666,
            ExecJS.exec( shuffled )
    end
end<commit_msg>Add last test, which already passes<commit_after>require 'test/unit'
require 'jsshuffle'
require 'execjs'

class ParameterRenamingTest < Test::Unit::TestCase
    def test_can_include
        assert_nothing_raised do
            @shuffler = JsShuffle::Shuffler.new use: :parameter_renaming
        end
    end

    def test_name_changes
        assert_nothing_raised do @shuffler = JsShuffle::Shuffler.new use: :parameter_renaming end
        original = %Q(
            function double(parameter) {
                return parameter*2;
            }
        )
        assert_not_equal original,
            @shuffler.shuffle( js: original )
    end

    def test_code_works
        assert_nothing_raised do @shuffler = JsShuffle::Shuffler.new use: :parameter_renaming end
        shuffled = @shuffler.shuffle js: %Q(
            function double(parameter) {
                return parameter*2;
            }
            return double(333);
        )
        assert_equal 666,
            ExecJS.exec( shuffled )
    end

    def test_references_updated
        assert_nothing_raised do @shuffler = JsShuffle::Shuffler.new use: :parameter_renaming end
        assert_no_match /parameter/,
            @shuffler.shuffle( js: %Q(
                function double(parameter) {
                    return parameter*2;
                }
                return double(333);
            ))
    end
end
{'fraction_non_alphanumeric': 0.07199665131854333, 'fraction_numerical': 0.008371703641691083, 'mean_word_length': 2.0176767676767677, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '103188', 'n_tokens_mistral': 716, 'n_tokens_neox': 672, 'n_words': 155}