<commit_before>require 'splib'
require 'test/unit'
require 'fileutils'

class CodeReloaderTest < Test::Unit::TestCase
    def setup
        @s = File.expand_path("#{__FILE__}/../../samplecode.rb")
        @s1 = File.expand_path("#{__FILE__}/../../samplecode1.rb")
        @s2 = File.expand_path("#{__FILE__}/../../samplecode2.rb")
        Splib.load :CodeReloader
        Splib.load :Constants
        FileUtils.cp @s1, @s
    end
    def teardown
        FileUtils.rm @s, :force => true
    end
    def test_load
        holder = Splib.load_code(@s)
        klass = Splib.find_const('Fu::Bar', [holder])
        obj = klass.new
        assert_equal('hello world', obj.foobar)
    end
    def test_reload
        holder = Splib.load_code(@s)
        klass = Splib.find_const('Fu::Bar', [holder])
        obj = klass.new
        assert(obj.respond_to?(:foobar))
        assert(!obj.respond_to?(:feebar))
        assert_equal('hello world', obj.foobar)
        FileUtils.cp @s2, @s
        Splib.reload_code(holder)
        klass = Splib.find_const('Fu::Bar', [holder])
        obj = klass.new
        assert(obj.respond_to?(:feebar))
        assert(!obj.respond_to?(:foobar))
        assert_equal('goodbye world', obj.feebar)
    end
end<commit_msg>use correctly<commit_after>require 'splib'
require 'test/unit'
require 'fileutils'

class CodeReloaderTest < Test::Unit::TestCase
    def setup
        @s = File.expand_path("#{__FILE__}/../../samplecode.rb")
        @s1 = File.expand_path("#{__FILE__}/../../samplecode1.rb")
        @s2 = File.expand_path("#{__FILE__}/../../samplecode2.rb")
        Splib.load :CodeReloader
        Splib.load :Constants
        FileUtils.cp @s1, @s
    end
    def teardown
        FileUtils.rm @s, :force => true
    end
    def test_load
        holder = Splib.load_code(@s)
        klass = Splib.find_const('Fu::Bar', [holder])
        obj = klass.new
        assert_equal('hello world', obj.foobar)
    end
    def test_reload
        holder = Splib.load_code(@s)
        klass = Splib.find_const('Fu::Bar', [holder])
        obj = klass.new
        assert(obj.respond_to?(:foobar))
        assert(!obj.respond_to?(:feebar))
        assert_equal('hello world', obj.foobar)
        FileUtils.cp @s2, @s
        holder = Splib.reload_code(holder)
        klass = Splib.find_const('Fu::Bar', [holder])
        obj = klass.new
        assert(obj.respond_to?(:feebar))
        assert(!obj.respond_to?(:foobar))
        assert_equal('goodbye world', obj.feebar)
    end
end
{'fraction_non_alphanumeric': 0.1497005988023952, 'fraction_numerical': 0.004790419161676647, 'mean_word_length': 2.4517906336088156, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '4482175', 'n_tokens_mistral': 866, 'n_tokens_neox': 841, 'n_words': 151}