Method: CodeRunner::Run::FortranNamelist.add_variable_should_pass

Defined in:
lib/coderunner/fortran_namelist.rb

.add_variable_should_pass(namelist = nil, var, tst) ⇒ Object

Add a test which the variable should pass before being included in the input file. The parameter tst must be of the form: { test: test_string explanation: explanation_string } where test_string is a string such that variable_value.instance_eval(test_string) should be true when the variable_value passes the test. The explanation should be a string which explains what the test does. If variable_value fails the test, a warning is given.



469
470
471
472
473
474
475
476
477
478
# File 'lib/coderunner/fortran_namelist.rb', line 469

def self.add_variable_should_pass(namelist=nil, var, tst)
	unless namelist
		namelist = rcp.namelists.find{|n, nh| nh[:variables].keys.include? var}[0]
		eputs "Editing namelist #{namelist}"; STDIN.gets
	end
	rcp.namelists[namelist][:variables][var][:should_pass] ||= []
	rcp.namelists[namelist][:variables][var][:should_pass].push tst
	rcp.namelists[namelist][:variables][var][:should_pass].uniq!
	save_namelists
end