Sha256: 941d2a0331f9fceccac91bd5c170788763adc07e7a03c28425139374881861cd

Contents?: true

Size: 1 KB

Versions: 58

Compression:

Stored size: 1 KB

Contents

import ceylon.test { ... }

// Tests adapted from problem-specifications 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

58 entries across 58 versions & 1 rubygems

Version Path
trackler-2.2.1.88 tracks/ceylon/exercises/bracket-push/source/bracketpush/BracketsTest.ceylon
trackler-2.2.1.87 tracks/ceylon/exercises/bracket-push/source/bracketpush/BracketsTest.ceylon
trackler-2.2.1.86 tracks/ceylon/exercises/bracket-push/source/bracketpush/BracketsTest.ceylon
trackler-2.2.1.85 tracks/ceylon/exercises/bracket-push/source/bracketpush/BracketsTest.ceylon
trackler-2.2.1.84 tracks/ceylon/exercises/bracket-push/source/bracketpush/BracketsTest.ceylon
trackler-2.2.1.83 tracks/ceylon/exercises/bracket-push/source/bracketpush/BracketsTest.ceylon
trackler-2.2.1.82 tracks/ceylon/exercises/bracket-push/source/bracketpush/BracketsTest.ceylon
trackler-2.2.1.81 tracks/ceylon/exercises/bracket-push/source/bracketpush/BracketsTest.ceylon
trackler-2.2.1.80 tracks/ceylon/exercises/bracket-push/source/bracketpush/BracketsTest.ceylon
trackler-2.2.1.79 tracks/ceylon/exercises/bracket-push/source/bracketpush/BracketsTest.ceylon
trackler-2.2.1.78 tracks/ceylon/exercises/bracket-push/source/bracketpush/BracketsTest.ceylon
trackler-2.2.1.77 tracks/ceylon/exercises/bracket-push/source/bracketpush/BracketsTest.ceylon
trackler-2.2.1.76 tracks/ceylon/exercises/bracket-push/source/bracketpush/BracketsTest.ceylon
trackler-2.2.1.75 tracks/ceylon/exercises/bracket-push/source/bracketpush/BracketsTest.ceylon
trackler-2.2.1.74 tracks/ceylon/exercises/bracket-push/source/bracketpush/BracketsTest.ceylon
trackler-2.2.1.73 tracks/ceylon/exercises/bracket-push/source/bracketpush/BracketsTest.ceylon
trackler-2.2.1.72 tracks/ceylon/exercises/bracket-push/source/bracketpush/BracketsTest.ceylon
trackler-2.2.1.71 tracks/ceylon/exercises/bracket-push/source/bracketpush/BracketsTest.ceylon
trackler-2.2.1.70 tracks/ceylon/exercises/bracket-push/source/bracketpush/BracketsTest.ceylon
trackler-2.2.1.69 tracks/ceylon/exercises/bracket-push/source/bracketpush/BracketsTest.ceylon