<commit_before>import romanesco
import unittest


class TestSwiftMode(unittest.TestCase):
    def testSwiftMode(self):
        task = {
            'mode': 'swift',
            'script': """
type file;

app (file out) echo_app (string s)
{
   echo s stdout=filename(out);
}

string a = arg("a", "10");

file out <"out.csv">;
out = echo_app(strcat("a,b,c\\n", a, ",2,3"));
""",
            'inputs': [{
                'id': 'a',
                'format': 'json',
                'type': 'number'
            }],
            'swift_args': ['-a=$input{a}'],
            'outputs': [{
                'id': 'out.csv',
                'type': 'table',
                'format': 'csv'
            }]
        }

        inputs = {
            'a': {
                'format': 'number',
                'data': 5
            }
        }

        # Use user-specified filename
        out = romanesco.run(task, inputs=inputs)

        # We bound _stderr as a task output, so it should be in the output
        self.assertEqual(out, {<commit_msg>Remove comments that don't make sense<commit_after>import romanesco
import unittest


class TestSwiftMode(unittest.TestCase):
    def testSwiftMode(self):
        task = {
            'mode': 'swift',
            'script': """
type file;

app (file out) echo_app (string s)
{
   echo s stdout=filename(out);
}

string a = arg("a", "10");

file out <"out.csv">;
out = echo_app(strcat("a,b,c\\n", a, ",2,3"));
""",
            'inputs': [{
                'id': 'a',
                'format': 'json',
                'type': 'number'
            }],
            'swift_args': ['-a=$input{a}'],
            'outputs': [{
                'id': 'out.csv',
                'type': 'table',
                'format': 'csv'
            }]
        }

        inputs = {
            'a': {
                'format': 'number',
                'data': 5
            }
        }

        out = romanesco.run(task, inputs=inputs)

        self.assertEqual(out, {
{'fraction_non_alphanumeric': 0.16675062972292193, 'fraction_numerical': 0.005037783375314861, 'mean_word_length': 1.4398034398034398, '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': '122782', 'n_tokens_mistral': 642, 'n_tokens_neox': 603, 'n_words': 142}