<commit_before>package nextflow

import java.nio.file.Files
import java.nio.file.Paths

import groovyx.gpars.dataflow.DataflowVariable
import spock.lang.Specification


/**
 *
 * @author <NAME> <<EMAIL>>
 */
class ChannelTest extends Specification {

    def testGetPathAndPattern () {

        expect:
        Channel.getFolderAndPattern( '/some/file/name.txt' ) == ['/some/file/', 'name.txt']
        Channel.getFolderAndPattern( '/some/file/*.txt' ) == ['/some/file/', '*.txt']
        Channel.getFolderAndPattern( '/some/file/*' ) == ['/some/file/', '*']
        Channel.getFolderAndPattern( '/some/file/' ) == ['/some/file/', '']

        Channel.getFolderAndPattern( '/some/file/**/*.txt' ) == ['/some/file/', '**/*.txt']

        Channel.getFolderAndPattern( 'dxfs:///some/file/**/*.txt' ) == ['dxfs:///some/file/', '**/*.txt']
        Channel.getFolderAndPattern( 'dxfs://some/file/**/*.txt' ) == ['dxfs://some/file/', '**/*.txt']
        Channel.getFolderAndPattern( 'dxfs://*.txt' ) == ['dxfs://.', '*.txt']
        Channel.getFolderAndPattern( 'dxfs:///*.txt' ) == ['dxfs:///', '*.txt']
        Channel.getFolderAndPattern( 'dxfs:///**/*.txt' ) == ['dxfs:///', '**/*.txt']
    }


    def testSingleFile() {

        when:
        def channel = Channel.files('/some/file.txt')
        then:
        channel instanceof DataflowVariable
        channel.val == Paths.get('/some/file.txt')

        when:
        channel = Channel.files('/some/f{i}le.txt')
        then:
        channel instanceof DataflowVariable
        channel.val == Paths.get('/some/f{i}le.txt')

    }


    def testGlobAlternative() {

        setup:
        def folder = Files.createTempDirectory('testFiles')
        def file1 = Files.createFile(folder.resolve('alpha.txt'))
        def file2 = Files.createFile(folder.resolve('beta.txt'))
        def file3 = Files.createFile(folder.resolve('gamma.txt'))<commit_msg>Fixed test<commit_after>package nextflow
import java.nio.file.Files
import java.nio.file.Paths

import spock.lang.Specification
/**
 *
 * @author <NAME> <<EMAIL>>
 */
class ChannelTest extends Specification {

    def testGetPathAndPattern () {

        expect:
        Channel.getFolderAndPattern( '/some/file/name.txt' ) == ['/some/file/', 'name.txt']
        Channel.getFolderAndPattern( '/some/file/*.txt' ) == ['/some/file/', '*.txt']
        Channel.getFolderAndPattern( '/some/file/*' ) == ['/some/file/', '*']
        Channel.getFolderAndPattern( '/some/file/' ) == ['/some/file/', '']

        Channel.getFolderAndPattern( '/some/file/**/*.txt' ) == ['/some/file/', '**/*.txt']

        Channel.getFolderAndPattern( 'dxfs:///some/file/**/*.txt' ) == ['dxfs:///some/file/', '**/*.txt']
        Channel.getFolderAndPattern( 'dxfs://some/file/**/*.txt' ) == ['dxfs://some/file/', '**/*.txt']
        Channel.getFolderAndPattern( 'dxfs://*.txt' ) == ['dxfs://.', '*.txt']
        Channel.getFolderAndPattern( 'dxfs:///*.txt' ) == ['dxfs:///', '*.txt']
        Channel.getFolderAndPattern( 'dxfs:///**/*.txt' ) == ['dxfs:///', '**/*.txt']
    }


    def testSingleFile() {

        when:
        def channel = Channel.files('/some/file.txt')
        then:
        channel.val == Paths.get('/some/file.txt')

        when:
        channel = Channel.files('/some/f{i}le.txt')
        then:
        channel.val == Paths.get('/some/f{i}le.txt')

    }


    def testGlobAlternative() {

        setup:
        def folder = Files.createTempDirectory('testFiles')
        def file1 = Files.createFile(folder.resolve('alpha.txt'))
        def file2 = Files.createFile(folder.resolve('beta.txt'))
        def file3 = Files.createFile(folder.resolve('gamma.txt'))
{'fraction_non_alphanumeric': 0.2161792839573654, 'fraction_numerical': 0.001639792292976223, 'mean_word_length': 2.6094674556213016, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '6429053', 'n_tokens_mistral': 1215, 'n_tokens_neox': 1184, 'n_words': 180}