Sha256: 7ef23a9089fb514d186834d096c4d4a446412696c9db8f1aa4900508fa5b994f

Contents?: true

Size: 922 Bytes

Versions: 76

Compression:

Stored size: 922 Bytes

Contents

import ceylon.test { ... }

{[String, Boolean]*} cases => {
  // paired square brackets
  ["[]", true],
  // empty string
  ["", true],
  // unpaired brackets
  ["[[", false],
  // wrong ordered brackets
  ["}{", 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

76 entries across 76 versions & 1 rubygems

Version Path
trackler-2.0.8.22 tracks/ceylon/exercises/bracket-push/source/bracketpush/BracketsTest.ceylon
trackler-2.0.8.21 tracks/ceylon/exercises/bracket-push/source/bracketpush/BracketsTest.ceylon
trackler-2.0.8.20 tracks/ceylon/exercises/bracket-push/source/bracketpush/BracketsTest.ceylon
trackler-2.0.8.19 tracks/ceylon/exercises/bracket-push/source/bracketpush/BracketsTest.ceylon
trackler-2.0.8.18 tracks/ceylon/exercises/bracket-push/source/bracketpush/BracketsTest.ceylon
trackler-2.0.8.17 tracks/ceylon/exercises/bracket-push/source/bracketpush/BracketsTest.ceylon
trackler-2.0.8.16 tracks/ceylon/exercises/bracket-push/source/bracketpush/BracketsTest.ceylon
trackler-2.0.8.15 tracks/ceylon/exercises/bracket-push/source/bracketpush/BracketsTest.ceylon
trackler-2.0.8.14 tracks/ceylon/exercises/bracket-push/source/bracketpush/BracketsTest.ceylon
trackler-2.0.8.13 tracks/ceylon/exercises/bracket-push/source/bracketpush/BracketsTest.ceylon
trackler-2.0.8.12 tracks/ceylon/exercises/bracket-push/source/bracketpush/BracketsTest.ceylon
trackler-2.0.8.11 tracks/ceylon/exercises/bracket-push/source/bracketpush/BracketsTest.ceylon
trackler-2.0.8.10 tracks/ceylon/exercises/bracket-push/source/bracketpush/BracketsTest.ceylon
trackler-2.0.8.9 tracks/ceylon/exercises/bracket-push/source/bracketpush/BracketsTest.ceylon
trackler-2.0.8.8 tracks/ceylon/exercises/bracket-push/source/bracketpush/BracketsTest.ceylon
trackler-2.0.8.7 tracks/ceylon/exercises/bracket-push/source/bracketpush/BracketsTest.ceylon
trackler-2.0.8.6 tracks/ceylon/exercises/bracket-push/source/bracketpush/BracketsTest.ceylon
trackler-2.0.8.5 tracks/ceylon/exercises/bracket-push/source/bracketpush/BracketsTest.ceylon
trackler-2.0.8.4 tracks/ceylon/exercises/bracket-push/source/bracketpush/BracketsTest.ceylon
trackler-2.0.8.3 tracks/ceylon/exercises/bracket-push/source/bracketpush/BracketsTest.ceylon