Sha256: ce4e30b29cebd02aefa2b19ef70a9d886351c797b151227777c0cdabefac1794

Contents?: true

Size: 1011 Bytes

Versions: 105

Compression:

Stored size: 1011 Bytes

Contents

import ceylon.test { ... }

// Tests adapted from x-common version 1.1.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],
  // 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

105 entries across 105 versions & 1 rubygems

Version Path
trackler-2.2.1.30 tracks/ceylon/exercises/bracket-push/source/bracketpush/BracketsTest.ceylon
trackler-2.2.1.29 tracks/ceylon/exercises/bracket-push/source/bracketpush/BracketsTest.ceylon
trackler-2.2.1.28 tracks/ceylon/exercises/bracket-push/source/bracketpush/BracketsTest.ceylon
trackler-2.2.1.27 tracks/ceylon/exercises/bracket-push/source/bracketpush/BracketsTest.ceylon
trackler-2.2.1.26 tracks/ceylon/exercises/bracket-push/source/bracketpush/BracketsTest.ceylon
trackler-2.2.1.25 tracks/ceylon/exercises/bracket-push/source/bracketpush/BracketsTest.ceylon
trackler-2.2.1.24 tracks/ceylon/exercises/bracket-push/source/bracketpush/BracketsTest.ceylon
trackler-2.2.1.23 tracks/ceylon/exercises/bracket-push/source/bracketpush/BracketsTest.ceylon
trackler-2.2.1.22 tracks/ceylon/exercises/bracket-push/source/bracketpush/BracketsTest.ceylon
trackler-2.2.1.21 tracks/ceylon/exercises/bracket-push/source/bracketpush/BracketsTest.ceylon
trackler-2.2.1.20 tracks/ceylon/exercises/bracket-push/source/bracketpush/BracketsTest.ceylon
trackler-2.2.1.19 tracks/ceylon/exercises/bracket-push/source/bracketpush/BracketsTest.ceylon
trackler-2.2.1.18 tracks/ceylon/exercises/bracket-push/source/bracketpush/BracketsTest.ceylon
trackler-2.2.1.17 tracks/ceylon/exercises/bracket-push/source/bracketpush/BracketsTest.ceylon
trackler-2.2.1.16 tracks/ceylon/exercises/bracket-push/source/bracketpush/BracketsTest.ceylon
trackler-2.2.1.15 tracks/ceylon/exercises/bracket-push/source/bracketpush/BracketsTest.ceylon
trackler-2.2.1.14 tracks/ceylon/exercises/bracket-push/source/bracketpush/BracketsTest.ceylon
trackler-2.2.1.13 tracks/ceylon/exercises/bracket-push/source/bracketpush/BracketsTest.ceylon
trackler-2.2.1.12 tracks/ceylon/exercises/bracket-push/source/bracketpush/BracketsTest.ceylon
trackler-2.2.1.11 tracks/ceylon/exercises/bracket-push/source/bracketpush/BracketsTest.ceylon