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.98 tracks/crystal/exercises/bracket-push/spec/bracket_push_spec.cr
trackler-2.2.1.97 tracks/crystal/exercises/bracket-push/spec/bracket_push_spec.cr
trackler-2.2.1.96 tracks/crystal/exercises/bracket-push/spec/bracket_push_spec.cr
trackler-2.2.1.95 tracks/crystal/exercises/bracket-push/spec/bracket_push_spec.cr
trackler-2.2.1.94 tracks/crystal/exercises/bracket-push/spec/bracket_push_spec.cr
trackler-2.2.1.93 tracks/crystal/exercises/bracket-push/spec/bracket_push_spec.cr
trackler-2.2.1.92 tracks/crystal/exercises/bracket-push/spec/bracket_push_spec.cr
trackler-2.2.1.91 tracks/crystal/exercises/bracket-push/spec/bracket_push_spec.cr
trackler-2.2.1.90 tracks/crystal/exercises/bracket-push/spec/bracket_push_spec.cr
trackler-2.2.1.89 tracks/crystal/exercises/bracket-push/spec/bracket_push_spec.cr
trackler-2.2.1.88 tracks/crystal/exercises/bracket-push/spec/bracket_push_spec.cr
trackler-2.2.1.87 tracks/crystal/exercises/bracket-push/spec/bracket_push_spec.cr
trackler-2.2.1.86 tracks/crystal/exercises/bracket-push/spec/bracket_push_spec.cr
trackler-2.2.1.85 tracks/crystal/exercises/bracket-push/spec/bracket_push_spec.cr
trackler-2.2.1.84 tracks/crystal/exercises/bracket-push/spec/bracket_push_spec.cr
trackler-2.2.1.83 tracks/crystal/exercises/bracket-push/spec/bracket_push_spec.cr
trackler-2.2.1.82 tracks/crystal/exercises/bracket-push/spec/bracket_push_spec.cr
trackler-2.2.1.81 tracks/crystal/exercises/bracket-push/spec/bracket_push_spec.cr
trackler-2.2.1.80 tracks/crystal/exercises/bracket-push/spec/bracket_push_spec.cr
trackler-2.2.1.79 tracks/crystal/exercises/bracket-push/spec/bracket_push_spec.cr