Skip to content

Instantly share code, notes, and snippets.

@timfel
Created January 16, 2012 13:18
Show Gist options
  • Save timfel/1620825 to your computer and use it in GitHub Desktop.
Save timfel/1620825 to your computer and use it in GitHub Desktop.
require File.expand_path("../calculator.rb", __FILE__)
services = %w[172.16.59.95
172.16.59.124
172.16.59.243
172.16.57.39
172.16.58.233
172.16.57.12
172.16.56.214
172.16.59.172
172.16.59.146
172.16.57.114
172.16.56.161
172.16.56.97
172.16.56.136
172.16.58.239
172.16.59.227
172.16.57.97
172.16.58.174
172.16.56.95
172.16.57.112
172.16.56.48
172.16.56.248
172.16.56.94
172.16.58.231
172.16.56.144
172.16.59.192
172.16.56.112
172.16.59.249
172.16.57.29
199.19.116.225
172.16.59.234
172.16.57.216].sort
client = CalcClient.new
services.each do |s|
print s.inspect
print ": "
client.add_operation("+", s, 9001)
client.add_operation("*", s, 9002)
client.add_operation("!", s, 9003)
client.add_operation("-", "172.16.59.124", 9004)
begin
print "+ "
a = client.send("+", 1, 2).values.first.evaluate
raise unless a
raise unless a.is_a?(Calculator.types["Reply"])
rescue Exception => e
puts "FAIL!"
next
end
begin
print "* "
a = client.send("*", 1, 2).values.first.evaluate
raise unless a
raise unless a.is_a?(Calculator.types["Reply"])
rescue Exception => e
puts "FAIL!"
next
end
begin
print "! "
a = client.send("!", 2).values.first.evaluate
raise unless a
raise unless a.is_a?(Calculator.types["Reply"])
rescue Exception => e
puts "FAIL!"
next
end
begin
print "(- (+ 1 2) 2) "
a = client.send("-", client.send("+", 1, 2), 2).values.first.evaluate
raise unless a
raise unless a.is_a?(Calculator.types["Reply"])
rescue Exception => e
puts "FAIL!"
next
end
# begin
# client.send("+", client.send("-", 1, 2), 2).values.first.evaluate
# rescue Exception => e
# puts "#{s} failed at nested (+ (- 1 2) 2)"
# next
# end
puts "#{s} success"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment