Sha256: 65e89f2e4f382d72a08cae669628d020179d4f4bc1497f9cbe8d9e81bdc9a123

Contents?: true

Size: 1.14 KB

Versions: 36

Compression:

Stored size: 1.14 KB

Contents

#! /usr/bin/ruby
# -*- coding: utf-8 -*-

gem 'minitest', '=4.7.4'
require 'minitest/autorun'
require_relative '../../lib/y_petri'     # tested component itself
# require 'y_petri'
# require 'sy'

describe "Token game" do
  before do
    @m = YPetri::Agent.new
    @m.Place name: "A"
    @m.Place name: "B"
    @m.Place name: "C", marking: 7.77
    @m.Transition name: "A2B", stoichiometry: { A: -1, B: 1 }
    @m.Transition name: "C_decay", stoichiometry: { C: -1 }, rate: 0.05
  end

  it "should work" do
    @m.place( :A ).marking = 2
    @m.place( :B ).marking = 5
    @m.places.map( &:name ).must_equal [:A, :B, :C]
    @m.places.map( &:marking ).must_equal [2, 5, 7.77]
    @m.transition( :A2B ).arcs.must_equal [ @m.place( :A ), @m.place( :B ) ]
    @m.transition( :A2B ).fire!
    @m.places.map( &:marking ).must_equal [1, 6, 7.77]
    @m.transition( :A2B ).fire!
    @m.place( :A ).marking.must_equal 0
    @m.place( :B ).marking.must_equal 7
    2.times do @m.transition( :C_decay ).fire! 1 end
    @m.transition( :C_decay ).fire! 0.1
    200.times do @m.transition( :C_decay ).fire! 1 end
    assert_in_delta @m.place( :C ).marking, 0.00024, 0.00001
  end
end

Version data entries

36 entries across 36 versions & 1 rubygems

Version Path
y_petri-2.2.2 test/acceptance/token_game_test.rb
y_petri-2.2.1 test/acceptance/token_game_test.rb
y_petri-2.2.0 test/acceptance/token_game_test.rb
y_petri-2.1.51 test/acceptance/token_game_test.rb
y_petri-2.1.50 test/acceptance/token_game_test.rb
y_petri-2.1.49 test/acceptance/token_game_test.rb
y_petri-2.1.48 test/acceptance/token_game_test.rb
y_petri-2.1.47 test/acceptance/token_game_test.rb
y_petri-2.1.46 test/acceptance/token_game_test.rb
y_petri-2.1.45 test/acceptance/token_game_test.rb
y_petri-2.1.44 test/acceptance/token_game_test.rb
y_petri-2.1.42 test/acceptance/token_game_test.rb
y_petri-2.1.40 test/acceptance/token_game_test.rb
y_petri-2.1.39 test/acceptance/token_game_test.rb
y_petri-2.1.37 test/acceptance/token_game_test.rb
y_petri-2.1.36 test/acceptance/token_game_test.rb
y_petri-2.1.35 test/acceptance/token_game_test.rb
y_petri-2.1.34 test/acceptance/token_game_test.rb
y_petri-2.1.33 test/acceptance/token_game_test.rb
y_petri-2.1.31 test/acceptance/token_game_test.rb