File: rbasic.rb

package info (click to toggle)
ruby3.1 3.1.2-7%2Bdeb12u1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 132,892 kB
  • sloc: ruby: 1,154,753; ansic: 736,782; yacc: 46,445; pascal: 10,401; sh: 3,931; cpp: 1,158; python: 838; makefile: 787; asm: 462; javascript: 382; lisp: 97; sed: 94; perl: 62; awk: 36; xml: 4
file content (63 lines) | stat: -rw-r--r-- 1,960 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
describe :rbasic, shared: true do

  before :all do
    specs = CApiRBasicSpecs.new
    @taint = ruby_version_is(''...'3.1') ? specs.taint_flag : 0
    @freeze = specs.freeze_flag
  end

  it "reports the appropriate FREEZE flag for the object when reading" do
    obj, _ = @data.call
    initial = @specs.get_flags(obj)
    obj.freeze
    @specs.get_flags(obj).should == @freeze | initial
  end

  it "supports setting the FREEZE flag" do
    obj, _ = @data.call
    initial = @specs.get_flags(obj)
    @specs.set_flags(obj, @freeze | initial).should == @freeze | initial
    obj.should.frozen?
  end

  ruby_version_is ""..."2.7" do
    it "reports the appropriate FREEZE and TAINT flags for the object when reading" do
      obj, _ = @data.call
      initial = @specs.get_flags(obj)
      obj.taint
      @specs.get_flags(obj).should == @taint | initial
      obj.untaint
      @specs.get_flags(obj).should == initial
      obj.freeze
      @specs.get_flags(obj).should == @freeze | initial

      obj, _ = @data.call
      obj.taint
      obj.freeze
      @specs.get_flags(obj).should == @freeze | @taint | initial
    end

    it "supports setting the FREEZE and TAINT flags" do
      obj, _ = @data.call
      initial = @specs.get_flags(obj)
      @specs.set_flags(obj, @taint | initial).should == @taint | initial
      obj.should.tainted?
      @specs.set_flags(obj, initial).should == initial
      obj.should_not.tainted?
      @specs.set_flags(obj, @freeze | initial).should == @freeze | initial
      obj.should.frozen?

      obj, _ = @data.call
      @specs.set_flags(obj, @freeze | @taint | initial).should == @freeze | @taint | initial
      obj.should.tainted?
      obj.should.frozen?
    end
  end

  it "supports retrieving the (meta)class" do
    obj, _ = @data.call
    @specs.get_klass(obj).should == obj.class
    obj.singleton_class # ensure the singleton class exists
    @specs.get_klass(obj).should == obj.singleton_class
  end
end