Code coverage report for sc/classlib/Core/Boolean.js

Statements: 100% (52 / 52)      Branches: 100% (0 / 0)      Functions: 100% (19 / 19)      Lines: 100% (52 / 52)      Ignored: none     

All files » sc/classlib/Core/ » Boolean.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 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 1261     1   1 1 1   1 1 1780     1 20     1   1 4                         1 1             1   1 1 1 1     1     1 1     1     1   1 1     1   1     21     1   1     1     1 1     1 1       1 1     1     1   1   1 1     1   1     1     1   1 1     1 1        
SCScript.install(function(sc) {
  "use strict";
 
  require("./Object");
 
  var $ = sc.lang.$;
  var $int0 = $.int0;
  var $int1 = $.int1;
 
  sc.lang.klass.refine("Boolean", function(builder) {
    builder.addMethod("__bool__", function() {
      return this._;
    });
 
    builder.addMethod("toString", function() {
      return String(this._);
    });
 
    builder.shouldUseLiterals("new");
 
    builder.addMethod("xor", function($bool) {
      return $.Boolean(this === $bool).not();
    });
 
    // TODO: implements if
    // TODO: implements nop
    // TODO: implements &&
    // TODO: implements ||
    // TODO: implements and
    // TODO: implements or
    // TODO: implements nand
    // TODO: implements asInteger
    // TODO: implements binaryValue
 
    builder.addMethod("asBoolean");
    builder.addMethod("booleanValue");
 
    // TODO: implements keywordWarnings
    // TODO: implements trace
    // TODO: implements printOn
    // TODO: implements storeOn
 
    builder.addMethod("archiveAsCompileString", sc.TRUE);
 
    builder.addMethod("while", function() {
      var msg = "While was called with a fixed (unchanging) Boolean as the condition. ";
      msg += "Please supply a Function instead.";
      throw new Error(msg);
    });
 
    builder.addMethod("shallowCopy");
  });
 
  sc.lang.klass.refine("True", function(builder) {
    builder.addMethod("if", {
      args: "trueFunc"
    }, function($trueFunc) {
      return $trueFunc.value();
    });
 
    builder.addMethod("not", sc.FALSE);
 
    builder.addMethod("&&", function($that) {
      return $that.value();
    });
 
    builder.addMethod("||");
 
    builder.addMethod("and", {
      args: "that"
    }, function($that) {
      return $that.value();
    });
 
    builder.addMethod("or");
 
    builder.addMethod("nand", {
      args: "that"
    }, function($that) {
      return $that.value().$("not");
    });
 
    builder.addMethod("asInteger", function() {
      return $int1;
    });
 
    builder.addMethod("binaryValue", function() {
      return $int1;
    });
  });
 
  sc.lang.klass.refine("False", function(builder) {
    builder.addMethod("if", {
      args: "trueFunc; falseFunc"
    }, function($trueFunc, $falseFunc) {
      return $falseFunc.value();
    });
 
    builder.addMethod("not", sc.TRUE);
 
    builder.addMethod("&&");
 
    builder.addMethod("||", function($that) {
      return $that.value();
    });
 
    builder.addMethod("and");
 
    builder.addMethod("or", {
      args: "that"
    }, function($that) {
      return $that.value();
    });
 
    builder.addMethod("nand", sc.TRUE);
 
    builder.addMethod("asInteger", function() {
      return $int0;
    });
 
    builder.addMethod("binaryValue", function() {
      return $int0;
    });
  });
});