All files / src/elm overloaded.coffee

92.86% Statements 91/98
96.15% Branches 75/78
94.29% Functions 33/35
92.78% Lines 90/97

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210120x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x   1x   2652x     157x       1x   1406x     37x               1x                 1x   244x     33x 2x 31x         1x   208x     25x 2x 23x         1x   206x     26x 2x 24x         1x   53x     14x 4x 2x     1x   413x 413x     67x 3x 64x         1x   407x 407x     65x 3x 62x         1x   364x 364x     50x   50x         1x   364x 364x     50x   50x         1x   124x 124x     25x   25x         1x   132x 132x     27x 2x 25x         1x   36x     10x     1x   663x 663x     83x 6x 77x         1x   663x 663x     83x 6x 77x         1x   2593x 2593x     89x    
I{ Expression } = require './expression'
{ ThreeValuedLogic } = require '../datatypes/logic'
{ DateTime } = require '../datatypes/datetime'
{ Exception } = require '../datatypes/exception'
{ typeIsArray } = require '../util/util'
{ equals, equivalent } = require '../util/comparison'
{ build } = require './builder'
DT = require './datetime'
LIST = require './list'
IVL = require './interval'
STRING = require './string'
 
module.exports.Equal = class Equal extends Expression
  constructor: (json) ->
    super
 
  exec: (ctx) ->
    args = @execArgs(ctx)
    return null unless args[0]? and args[1]?
    equals @execArgs(ctx)...
 
module.exports.Equivalent = class Equivalent extends Expression
  constructor: (json) ->
    super
 
  exec: (ctx) ->
    [a, b] = @execArgs(ctx)
    if not a? and not b?
      true
    else if not a? or not b?
      false
    else
      equivalent(a, b)
 
module.exports.NotEqual = class NotEqual extends Expression
  constructor: (json) ->
    super
 
  exec: (ctx) ->
    args = @execArgs(ctx)
    return null unless args[0]? and args[1]?
    ThreeValuedLogic.not equals @execArgs(ctx)...
 
module.exports.Union = class Union extends Expression
  constructor: (json) ->
    super
 
  exec: (ctx) ->
    [a, b] = @execArgs ctx
    if not a? or not b? then return null
    lib = switch
      when typeIsArray(a) then LIST
      else IVL
    lib.doUnion(a, b)
 
module.exports.Except = class Except extends Expression
  constructor: (json) ->
    super
 
  exec: (ctx) ->
    [a, b] = @execArgs ctx
    if not a? or not b? then return null
    lib = switch
      when typeIsArray(a) then LIST
      else IVL
    lib.doExcept(a, b)
 
module.exports.Intersect = class Intersect extends Expression
  constructor: (json) ->
    super
 
  exec: (ctx) ->
    [a, b] = @execArgs ctx
    if not a? or not b? then return null
    lib = switch
      when typeIsArray(a) then LIST
      else IVL
    lib.doIntersect(a, b)
 
module.exports.Indexer = class Indexer extends Expression
  constructor: (json) ->
    super
 
  exec: (ctx) ->
    [operand, index] = @execArgs ctx
    if not operand? or not index? then return null
    if index < 0 or index >= operand.length then return null
    operand[index]
 
module.exports.In = class In extends Expression
  constructor: (json) ->
    super
    @precision = json.precision?.toLowerCase()
 
  exec: (ctx) ->
    [item, container] = @execArgs ctx
    if not container? or not item? then return null
    lib = switch
      when typeIsArray(container) then LIST
      else IVL
    lib.doContains(container, item, @precision)
 
module.exports.Contains = class Contains extends Expression
  constructor: (json) ->
    super
    @precision = json.precision?.toLowerCase()
 
  exec: (ctx) ->
    [container, item] = @execArgs ctx
    if not container? or not item? then return null
    lib = switch
      when typeIsArray(container) then LIST
      else IVL
    lib.doContains(container, item, @precision)
 
module.exports.Includes = class Includes extends Expression
  constructor: (json) ->
    super
    @precision = json.precision?.toLowerCase()
 
  exec: (ctx) ->
    [container, contained] = @execArgs ctx
    if not container? or not contained? then return null
    lib = switch
      when typeIsArray(container) then LIST
      else IVL
    lib.doIncludes(container, contained, @precision)
 
module.exports.IncludedIn = class IncludedIn extends Expression
  constructor: (json) ->
    super
    @precision = json.precision?.toLowerCase()
 
  exec: (ctx) ->
    [contained, container] = @execArgs ctx
    if not container? or not contained? then return null
    lib = switch
      when typeIsArray(container) then LIST
      else IVL
    lib.doIncludes(container, contained, @precision)
 
module.exports.ProperIncludes = class ProperIncludes extends Expression
  constructor: (json) ->
    super
    @precision = json.precision?.toLowerCase()
 
  exec: (ctx) ->
    [container, contained] = @execArgs ctx
    if not container? or not contained? then return null
    lib = switch
      when typeIsArray(container) then LIST
      else IVL
    lib.doProperIncludes(container, contained, @precision)
 
module.exports.ProperIncludedIn = class ProperIncludedIn extends Expression
  constructor: (json) ->
    super
    @precision = json.precision?.toLowerCase()
 
  exec: (ctx) ->
    [contained, container] = @execArgs ctx
    if not container? or not contained? then return null
    lib = switch
      when typeIsArray(container) then LIST
      else IVL
    lib.doProperIncludes(container, contained, @precision)
 
module.exports.Length = class Length extends Expression
  constructor: (json) ->
    super
 
  exec: (ctx) ->
    arg = @execArgs ctx
    if arg? then arg.length else null
 
module.exports.After = class After extends Expression
  constructor: (json) ->
    super
    @precision = json.precision?.toLowerCase()
 
  exec: (ctx) ->
    [a, b] = @execArgs(ctx)
    if not a? or not b? then return null
    lib = switch
      when a instanceof DateTime then DT
      else IVL
    lib.doAfter(a, b, @precision)
 
module.exports.Before = class After extends Expression
  constructor: (json) ->
    super
    @precision = json.precision?.toLowerCase()
 
  exec: (ctx) ->
    [a, b] = @execArgs(ctx)
    if not a? or not b? then return null
    lib = switch
      when a instanceof DateTime then DT
      else IVL
    lib.doBefore(a, b, @precision)
 
module.exports.SameAs = class SameAs extends Expression
  constructor: (json) ->
    super
    @precision = json.precision
 
  exec: (ctx) ->
    [a, b] = @execArgs(ctx)
    if a? and b? then a.sameAs(b, @precision?.toLowerCase()) else null