Module: Funit::Assertions
- Included in:
- Funit
- Defined in:
- lib/funit/assertions.rb
Instance Method Summary collapse
- #isequal(line) ⇒ Object
- #isequalwithin(line) ⇒ Object
- #isfalse(line) ⇒ Object
- #isrealequal(line) ⇒ Object
- #istrue(line) ⇒ Object
- #writeAssert ⇒ Object
Instance Method Details
#isequal(line) ⇒ Object
82 83 84 85 86 87 88 89 |
# File 'lib/funit/assertions.rb', line 82 def isequal(line) line.match(/\((\w+\(.*\)|[^,]+),(.+)\)/) @type = 'IsEqual' @condition = ".not.(#$1==#$2)" = "\"#$1 (\",#$1,\") is not\", #$2" syntaxError("invalid body for #@type",@suiteName) unless $& writeAssert end |
#isequalwithin(line) ⇒ Object
72 73 74 75 76 77 78 79 80 |
# File 'lib/funit/assertions.rb', line 72 def isequalwithin(line) line.match(/\((.*)\)/) expected, actual, tolerance = *($1.get_args) @type = 'IsEqualWithin' @condition = ".not.(#{actual}+#{tolerance}.ge.#{expected} &\n .and.#{actual}-#{tolerance}.le.#{expected})" = "\"#{expected} (\",#{expected},\") is not\",#{actual},\"within\",#{tolerance}" syntaxError("invalid body for #@type",@suiteName) unless $& writeAssert end |
#isfalse(line) ⇒ Object
53 54 55 56 57 58 59 60 |
# File 'lib/funit/assertions.rb', line 53 def isfalse(line) line.match(/\((.+)\)/) @type = 'IsFalse' @condition = "#$1" = "\"#$1 is not false\"" syntaxError("invalid body for #@type",@suiteName) unless $1=~/\S+/ writeAssert end |
#isrealequal(line) ⇒ Object
62 63 64 65 66 67 68 69 70 |
# File 'lib/funit/assertions.rb', line 62 def isrealequal(line) line.match(/\((.*)\)/) expected, actual = *($1.get_args) @type = 'IsRealEqual' @condition = ".not.(#{expected}+2*spacing(real(#{expected})).ge.#{actual} &\n .and.#{expected}-2*spacing(real(#{expected})).le.#{actual})" = "\"#{actual} (\",#{actual},\") is not\",#{expected},\"within\",2*spacing(real(#{expected}))" syntaxError("invalid body for #@type",@suiteName) unless $& writeAssert end |
#istrue(line) ⇒ Object
44 45 46 47 48 49 50 51 |
# File 'lib/funit/assertions.rb', line 44 def istrue(line) line.match(/\((.+)\)/) @type = 'IsTrue' @condition = ".not.(#$1)" = "\"#$1 is not true\"" syntaxError("invalid body for #@type",@suiteName) unless $1=~/\S+/ writeAssert end |
#writeAssert ⇒ Object
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 |
# File 'lib/funit/assertions.rb', line 91 def writeAssert " ! \#@type assertion\n numAsserts = numAsserts + 1\n if (noAssertFailed) then\nif (\#@condition) then\n print *, \" *\#@type failed* in test \#@testName &\n &[\#{@suiteName}.fun:\#{@lineNumber.to_s}]\"\n print *, \" \", \#@message\n print *, \"\"\n noAssertFailed = .false.\n numFailures = numFailures + 1\nelse\n numAssertsTested = numAssertsTested + 1\nendif\n endif\n OUTPUT\nend\n" |