Sha256: 09d2fdf743648df429c96da864a4162f7000a5c989c946fededf8fc3d0f7aad2
Contents?: true
Size: 1.19 KB
Versions: 1
Compression:
Stored size: 1.19 KB
Contents
require 'test/unit' require 'yargi' module Yargi # Here to check that what's in the documentation is correct class DocumentationTest < Test::Unit::TestCase module Source; end module Sink; end def test_README_example # create a directed graph digraph = Yargi::Digraph.new # create 10 source and 5 sink vertices, tag them with user modules sources = digraph.add_n_vertices(5, Source) assert VertexSet===sources # connect source to sink states edges = digraph.connect(sources, sources) assert EdgeSet===edges # put some dot attributes sources.add_marks(:shape => 'circle', :label => '') edges.add_marks do |e| {:label => "From #{e.source.index} to #{e.target.index}"} end # and print it dir = File.expand_path(File.dirname(__FILE__)) dotfile = File.join(dir,"README-example.dot") gitfile = File.join(dir,"README-example.gif") File.open(dotfile, 'w') {|f| f << digraph.to_dot} begin `dot -Tgif -o #{gitfile} #{dotfile}` rescue => ex $stderr.puts "dot test failed, probably not installed\n#{ex.message}" end end end # class DocumentationTest end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
yargi-0.2.0 | test/yargi/documentation_test.rb |