Code coverage report for sc/classlib/Math/Number.js

Statements: 100% (31 / 31)      Branches: 100% (0 / 0)      Functions: 100% (9 / 9)      Lines: 100% (31 / 31)      Ignored: none     

All files » sc/classlib/Math/ » Number.js
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 761     1   1   1 1   1 1 1 1 1 1 1   1 29   29 113           1   1 1     1   1 1             1     1       1     1     1       1     1     1       1        
SCScript.install(function(sc) {
  "use strict";
 
  require("./Magnitude");
 
  var $ = sc.lang.$;
 
  sc.lang.klass.refine("Number", function(builder) {
    builder.addMethod("isNumber", sc.TRUE);
 
    builder.subclassResponsibility("+");
    builder.subclassResponsibility("-");
    builder.subclassResponsibility("*");
    builder.subclassResponsibility("/");
    builder.subclassResponsibility("mod");
    builder.subclassResponsibility("div");
    builder.subclassResponsibility("pow");
 
    builder.addMethod("performBinaryOpOnSeqColl", function($aSelector, $aSeqColl, $adverb) {
      var $this = this;
 
      return $aSeqColl.$("collect", [ $.Func(function($item) {
        return $item.perform($aSelector, $this, $adverb);
      }) ]);
    });
 
    // TODO: implements performBinaryOpOnPoint
 
    builder.addMethod("rho");
 
    builder.addMethod("theta", function() {
      return $.Float(0.0);
    });
 
    builder.addMethod("real");
 
    builder.addMethod("imag", function() {
      return $.Float(0.0);
    });
 
    // TODO: implements @
    // TODO: implements complex
    // TODO: implements polar
 
    builder.addMethod("for", {
      args: "endValue; function"
    }, function($endValue, $function) {
      sc.lang.iterator.execute(
        sc.lang.iterator.number$for(this, $endValue),
        $function
      );
      return this;
    });
 
    builder.addMethod("forBy", {
      args: "endValue; stepValue; function"
    }, function($endValue, $stepValue, $function) {
      sc.lang.iterator.execute(
        sc.lang.iterator.number$forBy(this, $endValue, $stepValue),
        $function
      );
      return this;
    });
 
    builder.addMethod("forSeries", {
      args: "second; last; function"
    }, function($second, $last, $function) {
      sc.lang.iterator.execute(
        sc.lang.iterator.number$forSeries(this, $second, $last),
        $function
      );
      return this;
    });
  });
});