summaryrefslogtreecommitdiff
path: root/ruby/test/Slice/macros/Client.rb
blob: 3dc25dcf49fb5f6aab62ba0c5053b5eb7c094a85 (plain)
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
#!/usr/bin/env ruby
# **********************************************************************
#
# Copyright (c) 2003-2015 ZeroC, Inc. All rights reserved.
#
# This copy of Ice is licensed to you under the terms described in the
# ICE_LICENSE file included in this distribution.
#
# **********************************************************************

require 'pathname'

rubyDir = nil
for toplevel in [".", "..", "../..", "../../..", "../../../.."]
    path = Pathname.new(toplevel).join("ruby", "Ice.rb")
    if path.file?
        rubyDir = Pathname.new(toplevel).join("ruby")
        break
    end
end
if not rubyDir
    fail "can't find toplevel directory!"
end

require 'Ice'
Ice::loadSlice('Test.ice')

def test(b)
    if !b
        raise RuntimeError, 'test assertion failed'
    end
end

status = true

begin
    print "testing Slice predefined macros... "
    STDOUT.flush
    d = Test::Default.new
    test(d.x == 10)
    test(d.y == 10)

    nd = Test::NoDefault.new
    test(nd.x != 10)
    test(nd.y != 10)

    c = Test::RubyOnly.new
    test(c.lang.eql? "ruby")
    test(c.version == Ice::intVersion())
    puts "ok"
rescue => ex
    puts $!
    print ex.backtrace.join("\n")
    status = false
end

exit(status ? 0 : 1)