<commit_before>package test.jycessing;

import static junit.framework.Assert.assertEquals;

import java.io.ByteArrayOutputStream;
import java.io.PrintStream;

import jycessing.Runner;

import org.junit.Test;
import org.junit.runner.JUnitCore;

public class JycessingTests {

    private static String run(final String testResource) throws Exception {
        final ByteArrayOutputStream baos = new ByteArrayOutputStream();
        final PrintStream saved = System.out;
        try {
            System.setOut(new PrintStream(baos, true));
            Runner.main(new String[] { "test_resources/test_" + testResource
                    + ".py" });
            return new String(baos.toByteArray()).replaceAll("\r\n", "\n")
                    .replaceAll("\r", "\n");
        } finally {
            System.setOut(saved);
        }
    }

    @Test
    public void inherit_str() throws Exception {
        assertEquals("cosmic\n12\n[12, 13]\n", run("inherit_str"));
    }

    @Test
    public void set_builtins() throws Exception {
        assertEquals("128\nset(['banana'])\n", run("set"));
    }

    @Test
    public void map_builtins() throws Exception {
        assertEquals("50\n13\n", run("map"));
    }

    @Test
    public void md5() throws Exception {
        assertEquals("bb649c83dd1ea5c9d9dec9a18df0ffe9\n", run("md5"));
    }

    @Test
    public void urllib2() throws Exception {
        assertEquals("OK\n", run("urllib2"));
    }

    @Test
    public void urllib() throws Exception {
        assertEquals("OK\n", run("urllib"));
    }

    @Test
    public void load_in_initializer() throws Exception {
        assertEquals("OK\n", run("load_in_initializer"));
    }

    public static void main(final String[] args) {
        JUnitCore.runClasses(JycessingTests.class);
    }
}<commit_msg>fix old tests; add new tests for std lib regressions<commit_after>package test.jycessing;

import static junit.framework.Assert.assertEquals;

import java.io.ByteArrayOutputStream;
import java.io.PrintStream;

import jycessing.Runner;

import org.junit.Test;
import org.junit.runner.JUnitCore;

public class JycessingTests {

    private static String run(final String testResource) throws Exception {
        final ByteArrayOutputStream baos = new ByteArrayOutputStream();
        final PrintStream saved = System.out;
        try {
            System.setOut(new PrintStream(baos, true));
            Runner.main(new String[] { "testing/test_resources/test_"
                    + testResource + ".py" });
            return new String(baos.toByteArray()).replaceAll("\r\n", "\n")
                    .replaceAll("\r", "\n");
        } finally {
            System.setOut(saved);
        }
    }

    private static void testImport(final String module) throws Exception {
        final ByteArrayOutputStream baos = new ByteArrayOutputStream();
        final PrintStream saved = System.out;
        try {
            System.setOut(new PrintStream(baos, true));
            final String testClass = module + "_test";
            final String bogusFileName = "<test " + module + ">";
            final String testText = "import " + module + "\nprint 'OK'";
            Runner.runSketch(new String[] { testClass }, bogusFileName,
                    testText);
            assertEquals("OK\n",
                    new String(baos.toByteArray()).replaceAll("\r\n", "\n")
                            .replaceAll("\r", "\n"));
        } finally {
            System.setOut(saved);
        }
    }

    @Test
    public void inherit_str() throws Exception {
        assertEquals("cosmic\n12\n[12, 13]\n", run("inherit_str"));
    }

    @Test
    public void set_builtins() throws Exception {
        assertEquals("128\nset(['banana'])\n", run("set"));
    }

    @Test
    public void map_builtins() throws Exception {
        assertEquals("50\n13\n", run("map"));
    }

    @Test
    public void md5() throws Exception {
        assertEquals("bb649c83dd1ea5c9d9dec9a18df0ffe9\n", run("md5"));
    }

    @Test
    public void urllib2() throws Exception {
        testImport("urllib2");
    }

    @Test
    public void urllib() throws Exception {
        testImport("urllib");
    }

    @Test
    public void load_in_initializer() throws Exception {
        assertEquals("OK\n", run("load_in_initializer"));
    }

    @Test
    public void datetime() throws Exception {
        testImport("datetime");
    }

    @Test
    public void calendar() throws Exception {
        testImport("calendar");
    }

    public static void main(final String[] args) {
        JUnitCore.runClasses(JycessingTests.class);
    }
}
{'fraction_non_alphanumeric': 0.12264763140817651, 'fraction_numerical': 0.013411204845338524, 'mean_word_length': 2.4559043348281016, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, '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': '5893587', 'n_tokens_mistral': 1369, 'n_tokens_neox': 1306, 'n_words': 304}