Sha256: fc3bc6f59386aaf9ae291c9c24866160d7b309174a950a40bfa5b63b68198dab

Contents?: true

Size: 1 KB

Versions: 27

Compression:

Stored size: 1 KB

Contents

import ceylon.test { ... }

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

27 entries across 27 versions & 1 rubygems

Version Path
trackler-2.2.1.116 tracks/ceylon/exercises/bracket-push/source/bracketpush/BracketsTest.ceylon
trackler-2.2.1.115 tracks/ceylon/exercises/bracket-push/source/bracketpush/BracketsTest.ceylon
trackler-2.2.1.114 tracks/ceylon/exercises/bracket-push/source/bracketpush/BracketsTest.ceylon
trackler-2.2.1.113 tracks/ceylon/exercises/bracket-push/source/bracketpush/BracketsTest.ceylon
trackler-2.2.1.111 tracks/ceylon/exercises/bracket-push/source/bracketpush/BracketsTest.ceylon
trackler-2.2.1.110 tracks/ceylon/exercises/bracket-push/source/bracketpush/BracketsTest.ceylon
trackler-2.2.1.109 tracks/ceylon/exercises/bracket-push/source/bracketpush/BracketsTest.ceylon
trackler-2.2.1.108 tracks/ceylon/exercises/bracket-push/source/bracketpush/BracketsTest.ceylon
trackler-2.2.1.107 tracks/ceylon/exercises/bracket-push/source/bracketpush/BracketsTest.ceylon
trackler-2.2.1.106 tracks/ceylon/exercises/bracket-push/source/bracketpush/BracketsTest.ceylon
trackler-2.2.1.105 tracks/ceylon/exercises/bracket-push/source/bracketpush/BracketsTest.ceylon
trackler-2.2.1.104 tracks/ceylon/exercises/bracket-push/source/bracketpush/BracketsTest.ceylon
trackler-2.2.1.103 tracks/ceylon/exercises/bracket-push/source/bracketpush/BracketsTest.ceylon
trackler-2.2.1.102 tracks/ceylon/exercises/bracket-push/source/bracketpush/BracketsTest.ceylon
trackler-2.2.1.101 tracks/ceylon/exercises/bracket-push/source/bracketpush/BracketsTest.ceylon
trackler-2.2.1.100 tracks/ceylon/exercises/bracket-push/source/bracketpush/BracketsTest.ceylon
trackler-2.2.1.99 tracks/ceylon/exercises/bracket-push/source/bracketpush/BracketsTest.ceylon
trackler-2.2.1.98 tracks/ceylon/exercises/bracket-push/source/bracketpush/BracketsTest.ceylon
trackler-2.2.1.97 tracks/ceylon/exercises/bracket-push/source/bracketpush/BracketsTest.ceylon
trackler-2.2.1.96 tracks/ceylon/exercises/bracket-push/source/bracketpush/BracketsTest.ceylon