File: bool_spec.cr

package info (click to toggle)
crystal 1.14.0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 24,384 kB
  • sloc: javascript: 6,400; sh: 695; makefile: 269; ansic: 121; python: 105; cpp: 77; xml: 32
file content (48 lines) | stat: -rw-r--r-- 1,106 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
require "spec"

describe "Bool" do
  describe "!" do
    it { (!true).should be_false }
    it { (!false).should be_true }
  end

  describe "|" do
    it { (false | false).should be_false }
    it { (false | true).should be_true }
    it { (true | false).should be_true }
    it { (true | true).should be_true }
  end

  describe "&" do
    it { (false & false).should be_false }
    it { (false & true).should be_false }
    it { (true & false).should be_false }
    it { (true & true).should be_true }
  end

  describe "^" do
    it { (false ^ false).should be_false }
    it { (false ^ true).should be_true }
    it { (true ^ false).should be_true }
    it { (true ^ true).should be_false }
  end

  describe "hash" do
    it { true.hash.should_not eq(false.hash) }
  end

  describe "to_unsafe" do
    it { true.to_unsafe.should eq(1) }
    it { false.to_unsafe.should eq(0) }
  end

  describe "to_s" do
    it { true.to_s.should eq("true") }
    it { false.to_s.should eq("false") }
  end

  describe "clone" do
    it { true.clone.should be_true }
    it { false.clone.should be_false }
  end
end