-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- implements SCAssociation - build v0.0.32
- Loading branch information
Showing
14 changed files
with
1,910 additions
and
228 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
SCScript.install(function(sc) { | ||
"use strict"; | ||
|
||
require("../Math/Magnitude"); | ||
|
||
var $SC = sc.lang.$SC; | ||
|
||
function SCAssociation(args) { | ||
this.__initializeWith__("Magnitude"); | ||
this._key = args.shift() || $SC.Nil(); | ||
this._value = args.shift() || $SC.Nil(); | ||
} | ||
|
||
sc.lang.klass.define(SCAssociation, "Association : Magnitude", function(spec, utils) { | ||
var $nil = utils.$nil; | ||
var $false = utils.$false; | ||
|
||
spec.valueOf = function() { | ||
return this._key.valueOf(); | ||
}; | ||
|
||
spec.key = function() { | ||
return this._key; | ||
}; | ||
|
||
spec.key_ = function($value) { | ||
this._key = $value || /* istanbul ignore next */ $nil; | ||
return this; | ||
}; | ||
|
||
spec.value = function() { | ||
return this._value; | ||
}; | ||
|
||
spec.value_ = function($value) { | ||
this._value = $value || /* istanbul ignore next */ $nil; | ||
return this; | ||
}; | ||
|
||
spec["=="] = function($anAssociation) { | ||
if ($anAssociation.key) { | ||
return this._key ["=="] ($anAssociation.key()); | ||
} | ||
return $false; | ||
}; | ||
|
||
// TODO: implements hash | ||
|
||
spec["<"] = function($anAssociation) { | ||
return this._key ["<"] ($anAssociation.key()); | ||
}; | ||
|
||
// TODO: implements printOn | ||
// TODO: implements storeOn | ||
// TODO: implements embedInStream | ||
// TODO: implements transformEvent | ||
|
||
}); | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
(function() { | ||
"use strict"; | ||
|
||
require("./Association"); | ||
|
||
var $SC = sc.lang.$SC; | ||
|
||
describe("SCAssociation", function() { | ||
var SCAssociation; | ||
before(function() { | ||
SCAssociation = $SC("Association"); | ||
this.createInstance = function($key, $value) { | ||
return SCAssociation.new($key, $value); | ||
}; | ||
}); | ||
it("#valueOf", function() { | ||
var instance, test; | ||
|
||
instance = this.createInstance($SC.Integer(1), $SC.Integer(2)); | ||
|
||
test = instance.valueOf(); | ||
expect(test).to.be.a("JSNumber").that.equals(1); | ||
}); | ||
it("<>value", function() { | ||
var instance, test; | ||
var $value; | ||
|
||
$value = sc.test.object(); | ||
|
||
instance = this.createInstance(); | ||
|
||
test = instance.value_($value); | ||
expect(test).to.equal(instance); | ||
|
||
test = instance.value(); | ||
expect(test).to.equal($value); | ||
}); | ||
it("<>key", function() { | ||
var instance, test; | ||
var $key; | ||
|
||
$key = sc.test.object(); | ||
|
||
instance = this.createInstance(); | ||
|
||
test = instance.key_($key); | ||
expect(test).to.equal(instance); | ||
|
||
test = instance.key(); | ||
expect(test).to.equal($key); | ||
}); | ||
it("#==", function() { | ||
var instance, test; | ||
var $anAssociation; | ||
|
||
instance = this.createInstance($SC.Integer(1), $SC.Integer(2)); | ||
|
||
$anAssociation = $SC.Nil(); | ||
test = instance ["=="] ($anAssociation); | ||
expect(test).to.be.a("SCBoolean").that.is.false; | ||
|
||
$anAssociation = SCAssociation.new(); | ||
test = instance ["=="] ($anAssociation); | ||
expect(test).to.be.a("SCBoolean").that.is.false; | ||
|
||
$anAssociation = SCAssociation.new($SC.Integer(1), $SC.Integer(3)); | ||
test = instance ["=="] ($anAssociation); | ||
expect(test).to.be.a("SCBoolean").that.is.true; | ||
}); | ||
it.skip("#hash", function() { | ||
}); | ||
it("#<", function() { | ||
var instance, test; | ||
var $anAssociation; | ||
|
||
instance = this.createInstance($SC.Integer(1), $SC.Integer(2)); | ||
|
||
$anAssociation = SCAssociation.new($SC.Integer(2), $SC.Integer(3)); | ||
test = instance ["<"] ($anAssociation); | ||
expect(test).to.be.a("SCBoolean").that.is.true; | ||
|
||
$anAssociation = SCAssociation.new($SC.Integer(0), $SC.Integer(3)); | ||
test = instance ["<"] ($anAssociation); | ||
expect(test).to.be.a("SCBoolean").that.is.false; | ||
}); | ||
it.skip("#printOn", function() { | ||
}); | ||
it.skip("#storeOn", function() { | ||
}); | ||
it.skip("#embedInStream", function() { | ||
}); | ||
it.skip("#transformEvent", function() { | ||
}); | ||
}); | ||
})(); |
Oops, something went wrong.