Class: TestArrayChain

Inherits:
Test::Unit::TestCase
  • Object
show all
Includes:
Test::Unit::Assertions
Defined in:
lib/tdl/testunit/test_array_chain.rb

Instance Method Summary collapse

Instance Method Details

#setupObject



8
9
10
# File 'lib/tdl/testunit/test_array_chain.rb', line 8

def setup 
    Tdl.PutsEnable = false
end

#test_0Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/tdl/testunit/test_array_chain.rb', line 12

def test_0
    sm = SdlModule.new(name: "test_new_sdl",out_sv_path: File.join(__dir__,"tmp"))

    sm.instance_exec(self) do |ts|
        DataInf_C().slaver   :ainf,dimension:[8,6,5]
        puts align_signal(ainf)
        ts.assert_instance_of(TdlSpace::ArrayChain,ainf[0],"Array Chain Class Error")
        ts.assert_equal(ainf[0][4][4,0].to_s,"ainf[0][4][4:0]".to_nq,"Array[0][4][4:0] Error")
        ts.assert_equal(ainf[3].to_s,"ainf[3]".to_nq,"Array[3] Error")
        ts.assert_instance_of(NqString,ainf[3].to_s,"返回ArrayChain类型不对")
        ts.assert_raises(TdlError,"Chain Error slice raise Failse") do 
            ainf[0][4,3][4,0]
        end
    end

    sm.gen_sv_module
end

#test_1Object



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
64
65
66
# File 'lib/tdl/testunit/test_array_chain.rb', line 30

def test_1
    sm = SdlModule.new(name: "test_new_sdl_2",out_sv_path: File.join(__dir__,"tmp"))

    sm.instance_exec(self) do |ts|
        DataInf_C().slaver   :ainf,dimension:[8,6,5]
        Def().logic(name:"tmp",dsize:1,dimension:[ 2,3,4])
        # ainf.valid
        # puts tmp[0][1][1]
        ts.assert_equal(tmp[0][1][2],'tmp[0][1][2]'.to_nq,"Array Chain of Logic 选择出错")
        ts.assert_equal(ainf.valid[0][2][1],'ainf.valid[0][2][1]'.to_nq,"ArrayChain of interface 选择出错")
    
        ts.assert_equal(ainf[0][1][2].valid,"ainf[0][1][2].valid".to_nq,"ArrayChain of interface method 选择出错")
        ts.assert_equal(ainf.valid[0][1][2],"ainf.valid[0][1][2]".to_nq,"ArrayChain of interface method 选择出错")


        # Assign do 
        #     tmp[1][1][1] <= ainf.valid[0][2][1]
        #     # "op".to_nq.<=() 
        # end
        ts.assert_raises(TdlError,"错误选择"){  tmp[2,0][2] }
        ts.assert_raises(TdlError,"错误选择"){  ainf[2,0][2] }
        ts.assert_raises(TdlError,"错误选择"){  tmp[2,0][2] }
        ts.assert_raises(NoMethodError,"错误选择"){  tmp[2][2].valid }
        ts.assert_raises(TdlError,"错误选择"){  ainf[0][1,0].valid }
        ts.assert_raises(TdlError,"错误选择"){  ainf.valid[2,0][2] }
        # ts.assert_raises(TdlError,"错误选择"){  ainf.valid[0][1,0] }

        ts.assert_nothing_raised("正确的选择") do 
            Assign do 
                tmp[1][1][1] <= ainf.valid[1][2][3]
                ainf[0][0][1].valid <= tmp[2][2][0]
            end
        end
    end

    sm.gen_sv_module
end

#test_2Object



68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# File 'lib/tdl/testunit/test_array_chain.rb', line 68

def test_2 
    sm = SdlModule.new(name: "test_new_sdl_3",out_sv_path: File.join(__dir__,"tmp"))
    sm.instance_exec(self) do |ts|
        DataInf_C().slaver   :ainf,dimension:[8,6,5]
        Def().logic(name:"tmp",dsize:1,dimension:[ 2,3,4])

        ts.assert_nothing_raised("Correct Select") do 
            Assign do 
                tmp[1][1][1] <= ainf.valid[1][2][3]
                ainf[0][0][1].valid <= tmp[2][2][0]
                ainf[0][0][1].data  <= 90
                ainf.data[0][1][2]  <= tmp[1][2][1,0]
                ainf[0][0][3].ready <= 1
                ainf.ready[2][2][1] <= 1
            end
        end
    end
    sm.gen_sv_module

end