aboutsummaryrefslogtreecommitdiff
path: root/suites/parenthesis.py
blob: a06fddaaadc5c2695e2608d0830f7ef3740cd80b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# ############################################################################ #
#                                                                              #
#                                                         :::      ::::::::    #
#    parenthesis.py                                     :+:      :+:    :+:    #
#                                                     +:+ +:+         +:+      #
#    By: charles <charles.cabergs@gmail.com>        +#+  +:+       +#+         #
#                                                 +#+#+#+#+#+   +#+            #
#    Created: 2020/07/15 18:24:57 by charles           #+#    #+#              #
#    Updated: 2020/07/15 18:24:57 by charles          ###   ########.fr        #
#                                                                              #
# ############################################################################ #

from suite import suite

@suite
def suite_parenthesis(test):
    test("(echo bonjour)")
    test("(echo bonjour )")
    test("( echo bonjour )")

    test("(echo a && echo b) && echo c")
    test("(echo a || echo b) || echo c")
    test("(ls doesnotexist || echo b) || echo c")
    test("(echo a || ls doesnotexist) || echo c")
    test("echo aa && (echo b && echo c)")
    test("ls doesnotexist || (echo b && echo c)")

    test("(echo bonjour > f1)", files=["f1"])
    test("(echo bonjour > f1 > f2 > f3)", files=["f1", "f2", "f3"])
    test("(echo bonjour > f1 > f2 > f3 > f4 > f5 > f6 > f7 > f8 > f9)",
            files=["f1", "f2", "f3", "f4", "f5", "f6", "f7", "f8", "f9"])

    test("(echo bonjour) > f1", files=["f1"])
    test("(echo bonjour) > f1 > f2 > f3", files=["f1", "f2", "f3"])
    test("(echo bonjour) > f1 > f2 > f3 > f4 > f5 > f6 > f7 > f8 > f9",
            files=["f1", "f2", "f3", "f4", "f5", "f6", "f7", "f8", "f9"])

    test("(cat -e < f1)", setup="echo bonjour > f1")
    test("(cat -e < f1 < f2 < f3)", setup="touch f1 f2 f3 f4; echo bonjour > f3")
    test("(cat -e < f1 < f2 < f3 < f4 < f5 < f6 < f7 < f8 < f9)",
            setup="touch f1 f2 f3 f4 f5 f6 f7 f8 f9; echo bonjour > f9")

    test("(cat -e) < f1", setup="echo bonjour > f1")
    test("(cat -e) < f1 < f2 < f3", setup="touch f1 f2 f3 f4; echo bonjour > f3")
    test("(cat -e) < f1 < f2 < f3 < f4 < f5 < f6 < f7 < f8 < f9",
            setup="touch f1 f2 f3 f4 f5 f6 f7 f8 f9; echo bonjour > f9")

    test("(echo bonjour > f1 > f2 > f3 > f4) > f5 > f6 > f7 > f8 > f9",
            files=["f1", "f2", "f3", "f4", "f5", "f6", "f7", "f8", "f9"])
    test("(cat -e < f1 < f2 < f3 < f4) < f5 < f6 < f7 < f8 < f9",
            setup="touch f1 f2 f3 f4 f5 f6 f7 f8 f9; echo bonjour > f4")

    test("(echo bonjour > f1) > f2", files=["f1", "f2"])
    test("(cat -e > f1) < f2", setup="ls -l / > f2", files=["f1"])

    test("(exit); echo bonjour")
    test("(echo bonjour; exit; echo aurevoir)")