Class: TestML::Library::Standard

Inherits:
TestML::Library show all
Includes:
Util
Defined in:
lib/testml/library/standard.rb

Instance Method Summary collapse

Methods included from Util

#bool, #list, #native, #none, #num, #str

Methods inherited from TestML::Library

#runtime

Instance Method Details

#Catch(*args) ⇒ Object



24
25
26
27
28
29
# File 'lib/testml/library/standard.rb', line 24

def Catch(*args)
  error = runtime.error \
    or fail "Catch called but no TestML error found"
  runtime.error = nil
  return str(error)
end

#Count(list) ⇒ Object



65
66
67
# File 'lib/testml/library/standard.rb', line 65

def Count(list)
  return num(list.list.value.size)
end

#Get(key) ⇒ Object



7
8
9
10
# File 'lib/testml/library/standard.rb', line 7

def Get(key)
  key = key.str.value
  return runtime.function.getvar(key)
end

#GetLabelObject

def Set(key, value)

  return runtime.function.setvar(key, value)
end


16
17
18
# File 'lib/testml/library/standard.rb', line 16

def GetLabel
  return str(runtime.get_label)
end

#Join(list, separator = nil) ⇒ Object



51
52
53
54
# File 'lib/testml/library/standard.rb', line 51

def Join(list, separator=nil)
  separator = separator ? separator.value : ''
  return str(list.list.value.map {|e| e.value}.join(separator))
end

#Lines(text) ⇒ Object



69
70
71
# File 'lib/testml/library/standard.rb', line 69

def Lines(text)
  return list(text.value.split(/\n/).map {|l| str(l)})
end

#List(*args) ⇒ Object

def Bool(object)

  return bool(object.bool.value)
end


47
48
49
# File 'lib/testml/library/standard.rb', line 47

def List(*args)
  return list(args)
end

#Not(bool_) ⇒ Object



56
57
58
# File 'lib/testml/library/standard.rb', line 56

def Not(bool_)
  return bool(bool_.bool.value ? false : true)
end

#Reverse(list) ⇒ Object



73
74
75
# File 'lib/testml/library/standard.rb', line 73

def Reverse(list)
  return list(list.list.value.reverse)
end

#Sort(list) ⇒ Object



77
78
79
# File 'lib/testml/library/standard.rb', line 77

def Sort(list)
  return list(list.list.value.sort {|a, b| a.value <=> b.value})
end

#Str(object) ⇒ Object



35
36
37
# File 'lib/testml/library/standard.rb', line 35

def Str(object)
  return str(object.str.value)
end

#Strip(string, part) ⇒ Object



81
82
83
84
85
# File 'lib/testml/library/standard.rb', line 81

def Strip(string, part)
  string = string.str.value
  part = part.str.value
  return str string.sub(part, '')
end

#Text(lines) ⇒ Object



60
61
62
63
# File 'lib/testml/library/standard.rb', line 60

def Text(lines)
  value = lines.list.value
  return str(((value.map {|l| l.value}) + ['']).join($/))
end

#Throw(msg) ⇒ Object



31
32
33
# File 'lib/testml/library/standard.rb', line 31

def Throw(msg)
  fail(msg.value)
end

#Type(var) ⇒ Object



20
21
22
# File 'lib/testml/library/standard.rb', line 20

def Type(var)
  return str(var.type)
end