Code coverage report for sc/classlib/Collections/Association.js

Statements: 100% (19 / 19)      Branches: 100% (2 / 2)      Functions: 100% (7 / 7)      Lines: 100% (19 / 19)      Ignored: none     

All files » sc/classlib/Collections/ » Association.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 441     1   1 1   1 1 1   1 18     1 26           1 3 2   1     1 1     1 2                
SCScript.install(function(sc) {
  "use strict";
 
  require("../Math/Magnitude");
 
  var $ = sc.lang.$;
  var $false = $.false;
 
  sc.lang.klass.refine("Association", function(builder, _) {
    builder.addProperty("<>", "key");
    builder.addProperty("<>", "value");
 
    builder.addMethod("valueOf", function() {
      return this._$key.valueOf();
    });
 
    builder.addClassMethod("new", function($key, $value) {
      return _.newCopyArgs(this, {
        key: $key,
        value: $value
      });
    });
 
    builder.addMethod("==", function($anAssociation) {
      if ($anAssociation.key) {
        return this._$key ["=="] ($anAssociation.$("key"));
      }
      return $false;
    });
 
    builder.addMethod("hash", function() {
      return this._$key.hash();
    });
 
    builder.addMethod("<", function($anAssociation) {
      return this._$key.$("<", [ $anAssociation.$("key") ]);
    });
    // TODO: implements printOn
    // TODO: implements storeOn
    // TODO: implements embedInStream
    // TODO: implements transformEvent
  });
});