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.43 tracks/ceylon/exercises/bracket-push/source/bracketpush/BracketsTest.ceylon
trackler-2.0.8.42 tracks/ceylon/exercises/bracket-push/source/bracketpush/BracketsTest.ceylon
trackler-2.0.8.41 tracks/ceylon/exercises/bracket-push/source/bracketpush/BracketsTest.ceylon
trackler-2.0.8.40 tracks/ceylon/exercises/bracket-push/source/bracketpush/BracketsTest.ceylon
trackler-2.0.8.39 tracks/ceylon/exercises/bracket-push/source/bracketpush/BracketsTest.ceylon
trackler-2.0.8.38 tracks/ceylon/exercises/bracket-push/source/bracketpush/BracketsTest.ceylon
trackler-2.0.8.37 tracks/ceylon/exercises/bracket-push/source/bracketpush/BracketsTest.ceylon
trackler-2.0.8.36 tracks/ceylon/exercises/bracket-push/source/bracketpush/BracketsTest.ceylon
trackler-2.0.8.35 tracks/ceylon/exercises/bracket-push/source/bracketpush/BracketsTest.ceylon
trackler-2.0.8.34 tracks/ceylon/exercises/bracket-push/source/bracketpush/BracketsTest.ceylon
trackler-2.0.8.33 tracks/ceylon/exercises/bracket-push/source/bracketpush/BracketsTest.ceylon
trackler-2.0.8.32 tracks/ceylon/exercises/bracket-push/source/bracketpush/BracketsTest.ceylon
trackler-2.0.8.31 tracks/ceylon/exercises/bracket-push/source/bracketpush/BracketsTest.ceylon
trackler-2.0.8.30 tracks/ceylon/exercises/bracket-push/source/bracketpush/BracketsTest.ceylon
trackler-2.0.8.29 tracks/ceylon/exercises/bracket-push/source/bracketpush/BracketsTest.ceylon
trackler-2.0.8.28 tracks/ceylon/exercises/bracket-push/source/bracketpush/BracketsTest.ceylon
trackler-2.0.8.27 tracks/ceylon/exercises/bracket-push/source/bracketpush/BracketsTest.ceylon
trackler-2.0.8.26 tracks/ceylon/exercises/bracket-push/source/bracketpush/BracketsTest.ceylon
trackler-2.0.8.24 tracks/ceylon/exercises/bracket-push/source/bracketpush/BracketsTest.ceylon
trackler-2.0.8.23 tracks/ceylon/exercises/bracket-push/source/bracketpush/BracketsTest.ceylon