Sha256: a3cee9ecad345fa730f3fbff095e480df69cc2af8f69570afb19c0e34923e430

Contents?: true

Size: 1.12 KB

Versions: 51

Compression:

Stored size: 1.12 KB

Contents

import ceylon.test {
    ...
}

// Tests adapted from problem-specifications version 1.3.0

{[String, Boolean]*} cases => {
    // paired square brackets
    ["[]", true],
    // empty string
    ["", true],
    // unpaired brackets
    ["[[", false],
    // wrong ordered brackets
    ["}{", false],
    // wrong closing bracket
    ["{]", false],
    // paired with whitespace
    ["{ }", true],
    // partially paired brackets
    ["{[])", false],
    // simple nested brackets
    ["{[]}", true],
    // several paired brackets
    ["{}[]", true],
    // paired and nested brackets
    ["([{}({}[])])", true],
    // unopened closing brackets
    ["{[)][]}", false],
    // unpaired and nested brackets
    ["([{])", false],
    // paired and wrong nested brackets
    ["[({]})", false],
    // math expression
    ["(((185 + 223.85) * 15) - 543)/2", true],
    // complex latex expression
    ["\\left(\\begin{array}{cc} \\frac{1}{3} & x\\\\ \\mathrm{e}^{x} &... x^2 \\end{array}\\right)", true]
};

test
parameters (`value cases`)
void testBalanced(String brackets, Boolean expected) {
    assertEquals(balanced(brackets), expected);
}

Version data entries

51 entries across 51 versions & 1 rubygems

Version Path
trackler-2.2.1.180 tracks/ceylon/exercises/bracket-push/source/bracketpush/BracketsTest.ceylon
trackler-2.2.1.179 tracks/ceylon/exercises/bracket-push/source/bracketpush/BracketsTest.ceylon
trackler-2.2.1.178 tracks/ceylon/exercises/bracket-push/source/bracketpush/BracketsTest.ceylon
trackler-2.2.1.177 tracks/ceylon/exercises/bracket-push/source/bracketpush/BracketsTest.ceylon
trackler-2.2.1.176 tracks/ceylon/exercises/bracket-push/source/bracketpush/BracketsTest.ceylon
trackler-2.2.1.175 tracks/ceylon/exercises/bracket-push/source/bracketpush/BracketsTest.ceylon
trackler-2.2.1.174 tracks/ceylon/exercises/bracket-push/source/bracketpush/BracketsTest.ceylon
trackler-2.2.1.173 tracks/ceylon/exercises/bracket-push/source/bracketpush/BracketsTest.ceylon
trackler-2.2.1.172 tracks/ceylon/exercises/bracket-push/source/bracketpush/BracketsTest.ceylon
trackler-2.2.1.171 tracks/ceylon/exercises/bracket-push/source/bracketpush/BracketsTest.ceylon
trackler-2.2.1.170 tracks/ceylon/exercises/bracket-push/source/bracketpush/BracketsTest.ceylon
trackler-2.2.1.169 tracks/ceylon/exercises/bracket-push/source/bracketpush/BracketsTest.ceylon
trackler-2.2.1.167 tracks/ceylon/exercises/bracket-push/source/bracketpush/BracketsTest.ceylon
trackler-2.2.1.166 tracks/ceylon/exercises/bracket-push/source/bracketpush/BracketsTest.ceylon
trackler-2.2.1.165 tracks/ceylon/exercises/bracket-push/source/bracketpush/BracketsTest.ceylon
trackler-2.2.1.164 tracks/ceylon/exercises/bracket-push/source/bracketpush/BracketsTest.ceylon
trackler-2.2.1.163 tracks/ceylon/exercises/bracket-push/source/bracketpush/BracketsTest.ceylon
trackler-2.2.1.162 tracks/ceylon/exercises/bracket-push/source/bracketpush/BracketsTest.ceylon
trackler-2.2.1.161 tracks/ceylon/exercises/bracket-push/source/bracketpush/BracketsTest.ceylon
trackler-2.2.1.160 tracks/ceylon/exercises/bracket-push/source/bracketpush/BracketsTest.ceylon