Sha256: d9b356e73156611deb44308d18d856bd166135818a9cdec323417adbfd4a4789

Contents?: true

Size: 1.38 KB

Versions: 382

Compression:

Stored size: 1.38 KB

Contents

require "spec"
require "../src/*"

describe "Brackets" do
  describe "#are_valid?" do
    it "paired square brackets" do
      Brackets.are_valid?("[]").should be_true
    end
    it "empty string" do
      Brackets.are_valid?("").should be_true
    end
    it "unpaired brackets" do
      Brackets.are_valid?("[[").should be_false
    end
    it "wrong ordered brackets" do
      Brackets.are_valid?("}{").should be_false
    end
    it "paired with whitespace" do
      Brackets.are_valid?("{ }").should be_true
    end
    it "simple nested brackets" do
      Brackets.are_valid?("{[]}").should be_true
    end
    it "several paired brackets" do
      Brackets.are_valid?("{}[]").should be_true
    end
    it "paired and nested brackets" do
      Brackets.are_valid?("([{}({}[])])").should be_true
    end
    it "unopened closing brackets" do
      Brackets.are_valid?("{[)][]}").should be_false
    end
    it "unpaired and nested brackets" do
      Brackets.are_valid?("([{])").should be_false
    end
    it "paired and wrong nested brackets" do
      Brackets.are_valid?("[({]})").should be_false
    end
    it "math expression" do
      Brackets.are_valid?("(((185 + 223.85) * 15) - 543)/2").should be_true
    end
    it "complex latex expression" do
      Brackets.are_valid?("\left(\begin{array}{cc} \frac{1}{3} & x\\ \mathrm{e}^{x} &... x^2 \end{array}\right)").should be_true
    end
  end
end

Version data entries

382 entries across 382 versions & 1 rubygems

Version Path
trackler-2.2.1.180 tracks/crystal/exercises/bracket-push/spec/bracket_push_spec.cr
trackler-2.2.1.179 tracks/crystal/exercises/bracket-push/spec/bracket_push_spec.cr
trackler-2.2.1.178 tracks/crystal/exercises/bracket-push/spec/bracket_push_spec.cr
trackler-2.2.1.177 tracks/crystal/exercises/bracket-push/spec/bracket_push_spec.cr
trackler-2.2.1.176 tracks/crystal/exercises/bracket-push/spec/bracket_push_spec.cr
trackler-2.2.1.175 tracks/crystal/exercises/bracket-push/spec/bracket_push_spec.cr
trackler-2.2.1.174 tracks/crystal/exercises/bracket-push/spec/bracket_push_spec.cr
trackler-2.2.1.173 tracks/crystal/exercises/bracket-push/spec/bracket_push_spec.cr
trackler-2.2.1.172 tracks/crystal/exercises/bracket-push/spec/bracket_push_spec.cr
trackler-2.2.1.171 tracks/crystal/exercises/bracket-push/spec/bracket_push_spec.cr
trackler-2.2.1.170 tracks/crystal/exercises/bracket-push/spec/bracket_push_spec.cr
trackler-2.2.1.169 tracks/crystal/exercises/bracket-push/spec/bracket_push_spec.cr
trackler-2.2.1.167 tracks/crystal/exercises/bracket-push/spec/bracket_push_spec.cr
trackler-2.2.1.166 tracks/crystal/exercises/bracket-push/spec/bracket_push_spec.cr
trackler-2.2.1.165 tracks/crystal/exercises/bracket-push/spec/bracket_push_spec.cr
trackler-2.2.1.164 tracks/crystal/exercises/bracket-push/spec/bracket_push_spec.cr
trackler-2.2.1.163 tracks/crystal/exercises/bracket-push/spec/bracket_push_spec.cr
trackler-2.2.1.162 tracks/crystal/exercises/bracket-push/spec/bracket_push_spec.cr
trackler-2.2.1.161 tracks/crystal/exercises/bracket-push/spec/bracket_push_spec.cr
trackler-2.2.1.160 tracks/crystal/exercises/bracket-push/spec/bracket_push_spec.cr