simple_test.rb revision d95c0de1fbdb66e2aa8d2dc223ad554413f1dc87
6515faa115664909351ac241763bcb374ff62608Jakub Jirutkarequire 'test_helper'
6515faa115664909351ac241763bcb374ff62608Jakub Jirutka
6515faa115664909351ac241763bcb374ff62608Jakub Jirutkaclass OntologyParser::SimpleTest < ActiveSupport::TestCase
6515faa115664909351ac241763bcb374ff62608Jakub Jirutka
6515faa115664909351ac241763bcb374ff62608Jakub Jirutka context "OntologyParser" do
6515faa115664909351ac241763bcb374ff62608Jakub Jirutka
6515faa115664909351ac241763bcb374ff62608Jakub Jirutka context 'parsing simple' do
6515faa115664909351ac241763bcb374ff62608Jakub Jirutka setup do
6515faa115664909351ac241763bcb374ff62608Jakub Jirutka @ontologies = []
6515faa115664909351ac241763bcb374ff62608Jakub Jirutka @symbols = []
6515faa115664909351ac241763bcb374ff62608Jakub Jirutka @axioms = []
6515faa115664909351ac241763bcb374ff62608Jakub Jirutka OntologyParser.parse open_fixture('test1.xml'),
6515faa115664909351ac241763bcb374ff62608Jakub Jirutka ontology: Proc.new{ |h| @ontologies << h },
6515faa115664909351ac241763bcb374ff62608Jakub Jirutka symbol: Proc.new{ |h| @symbols << h },
6515faa115664909351ac241763bcb374ff62608Jakub Jirutka axiom: Proc.new{ |h| @axioms << h }
6515faa115664909351ac241763bcb374ff62608Jakub Jirutka end
6515faa115664909351ac241763bcb374ff62608Jakub Jirutka
6515faa115664909351ac241763bcb374ff62608Jakub Jirutka should 'find logic' do
6515faa115664909351ac241763bcb374ff62608Jakub Jirutka assert_equal 'CASL', @ontologies.first['logic']
166f25a5d5574393fa492c049f8397f207c89b46Jakub Jirutka end
51ee5e0cec79793575ee8c64909b965a132a064dJakub Jirutka
166f25a5d5574393fa492c049f8397f207c89b46Jakub Jirutka should 'found all symbols' do
51ee5e0cec79793575ee8c64909b965a132a064dJakub Jirutka assert_equal 2, @symbols.count
51ee5e0cec79793575ee8c64909b965a132a064dJakub Jirutka end
51ee5e0cec79793575ee8c64909b965a132a064dJakub Jirutka
should 'found all axioms' do
assert_equal 1, @axioms.count
end
should 'have correct symbols' do
assert_equal [
{"name"=>"s", "range"=>"/home/till/CASL/Hets-lib/test/test1.casl:2.8", "kind" => "sort", "text"=>"sort s"},
{"name"=>"f", "range"=>"/home/till/CASL/Hets-lib/test/test1.casl:3.6", "kind" => "op", "text"=>"op f : s -> s"}
], @symbols
end
should 'have correct axioms' do
assert_equal [{
"text" => "forall x : s . f(x) = x %(Ax1)%"
}], @axioms
end
end
end
def open_fixture(name)
File.open("#{Rails.root}/test/fixtures/ontologies/xml/#{name}")
end
end