# assert [1..3].has_only(1) == false
# assert [3..3[.has_only(1) == true # empty collection
#
- # ENSURE `is_empty implies (return) == true`
+ # ENSURE `is_empty implies result == true`
fun has_only(item: E): Bool is abstract
# How many occurrences of `item` are in the collection?
# Create a substring.
#
- # assert "abcd".substring(1, 2) == "bc"
- # assert "abcd".substring(-1, ) == "a"
- # assert "abcd".substring(1, 0) == ""
- # assert "abcd".substring(2, 5) == "cd"
+ # assert "abcd".substring(1, 2) == "bc"
+ # assert "abcd".substring(-1, 2) == "a"
+ # assert "abcd".substring(1, 0) == ""
+ # assert "abcd".substring(2, 5) == "cd"
#
# A `from` index < 0 will be replaced by 0.
# Unless a `count` value is > 0 at the same time.
# Create a substring from `self` beginning at the `from` position
#
- # assert "abcd".substring_from(1) == "bcd"
- # assert "abcd".substring_from(-1) == "abcd"
- # assert "abcd".substring_from(2) == "cd"
+ # assert "abcd".substring_from(1) == "bcd"
+ # assert "abcd".substring_from(-1) == "abcd"
+ # assert "abcd".substring_from(2) == "cd"
#
# As with substring, a `from` index < 0 will be replaced by 0
fun substring_from(from: Int): String
#
# assert "123".to_f == 123.0
# assert "-1".to_f == -1.0
- # assert "-1.2e-3".to_f == -1.2e-3
+ # assert "-1.2e-3".to_f == -0.0012
fun to_f: Float
do
# Shortcut
# The comparison between two strings is done on a lexicographical basis
#
- # assert "aa" < "b" == true
+ # assert ("aa" < "b") == true
redef fun <(other)
do
if self.object_id == other.object_id then return false
# Unsafely cast a value to a new type
# ie the result share the same C variable but my have a different mcasttype
# NOTE: if the adaptation is useless then `value` is returned as it.
- # ENSURE: `(return).name == value.name`
+ # ENSURE: `result.name == value.name`
fun autoadapt(value: RuntimeVariable, mtype: MType): RuntimeVariable
do
mtype = self.anchor(mtype)
fun adapt_signature(m: MMethodDef, args: Array[RuntimeVariable]) is abstract
# Box or unbox a value to another type iff a C type conversion is needed
- # ENSURE: result.mtype.ctype == mtype.ctype
+ # ENSURE: `result.mtype.ctype == mtype.ctype`
fun autobox(value: RuntimeVariable, mtype: MType): RuntimeVariable is abstract
# Generate a polymorphic subtype test
# because "redef type U: Y". Therefore, Map[T, U] is bound to
# Map[B, Y]
#
- # ENSURE: `not self.need_anchor` implies `(return) == self`
- # ENSURE: `not (return).need_anchor`
+ # ENSURE: `not self.need_anchor` implies `result == self`
+ # ENSURE: `not result.need_anchor`
fun anchor_to(mmodule: MModule, anchor: MClassType): MType
do
if not need_anchor then return self
#
# REQUIRE: `super_mclass` is a super-class of `self`
# REQUIRE: `self.need_anchor` implies `anchor != null and self.can_resolve_for(anchor, null, mmodule)`
- # ENSURE: `(return).mclass = super_mclass`
+ # ENSURE: `result.mclass = super_mclass`
fun supertype_to(mmodule: MModule, anchor: nullable MClassType, super_mclass: MClass): MClassType
do
if super_mclass.arity == 0 then return super_mclass.mclass_type
# two function instead of one seems also to be a bad idea.
#
# REQUIRE: `can_resolve_for(mtype, anchor, mmodule)`
- # ENSURE: `not self.need_anchor` implies `(return) == self`
+ # ENSURE: `not self.need_anchor` implies `result == self`
fun resolve_for(mtype: MType, anchor: nullable MClassType, mmodule: MModule, cleanup_virtual: Bool): MType is abstract
# Can the type be resolved?
#
# REQUIRE: `anchor != null` implies `not anchor.need_anchor`
# REQUIRE: `mtype.need_anchor` implies `anchor != null and mtype.can_resolve_for(anchor, null, mmodule)`
- # ENSURE: `not self.need_anchor` implies `(return) == true`
+ # ENSURE: `not self.need_anchor` implies `result == true`
fun can_resolve_for(mtype: MType, anchor: nullable MClassType, mmodule: MModule): Bool is abstract
# Return the nullable version of the type
end
# The formal arguments of the type
- # ENSURE: `(return).length == self.mclass.arity`
+ # ENSURE: `result.length == self.mclass.arity`
var arguments: Array[MType] = new Array[MType]
redef fun to_s do return mclass.to_s