Warning: session_start(): open(/var/lib/php/sessions/sess_u073s6ij8eekn2m071sllit7vn, O_RDWR) failed: No space left on device (28) in /var/www/tb-usercake/models/config.php on line 51
Warning: session_start(): Failed to read session data: files (path: /var/lib/php/sessions) in /var/www/tb-usercake/models/config.php on line 51
set flag OurSyncCollections.
!include once #1034831 // Gazelle 22 Function Include for Testing
svoid test_leftArrowScript_objectScope(LASMultiClassLoader cl default new LASMultiClassLoader(mc())) {
// Accessing an instance field
S classPrefix = "scriptClasses.";
embedded O runScript(S code) {
var parser = enableScaffolding(new GazelleV_LeftArrowScriptParser()
.classDefPrefix(classPrefix)
.lasClassLoader(cl));
ret leftArrowVerbose(parser, code);
}
// Access instance field without "this"
assertEqualsVerbose(10, runScript([[
class X {
i: int <- 5
def j { i plus i }
}
new X, j
]]));
// Access superclass field without "this"
assertEqualsVerbose(10, runScript([[
class X {
i: int <- 5
}
class Y extends X {
def j { i plus i }
}
new Y, j
]]));
// Make sure locally declared variables shadow fields
assertEqualsVerbose(14, runScript([[
class X {
i: int <- 5
def j { i: int <- 7; i plus i }
}
new X, j
]]));
// Assign instance field without "this"
assertEqualsVerbose(10, runScript([[
class X {
i: int
def j { i <- 10; this }
}
new X, j, i
]]));
// Assign instance field in superclass without "this"
assertEqualsVerbose(10, runScript([[
class X { i: int }
class Y extends X {
def j { i <- 10; this }
}
new Y, j, i
]]));
// Call instance method without "this"
assertEqualsVerbose(2, runScript([[
class X {
i: int <- 1
def yo { i <- i plus 1 }
def j { yo; i }
}
new X, j
]]));
// Call instance method without "this" followed by "<"
assertEqualsVerbose(6, runScript([[
class X {
def yo n { 1 plus n }
def j { yo < 5 }
}
new X, j
]]));
// Special case: field & method with same name
// (refers to the field because it's inside an expression)
assertEqualsVerbose(ll("o", "o"), runScript([[
class X {
bla: S <- "o"
def bla { "x" }
def y { ll bla bla }
}
new X, y
]]));
// Call superclass method without "this"
assertEqualsVerbose(2, runScript([[
class X {
i: int <- 1
def yo { i <- i plus 1 }
}
class Y extends X {
def j { yo; i }
}
new Y, j
]]));
// Same with arguments and return value
assertEqualsVerbose(6, runScript([[
class X {
i: int <- 1
def yo x { i <- i plus x; this }
def j { yo 5, i }
}
new X, j
]]));
// Same with "<"
assertEqualsVerbose(6, runScript([[
class X {
i: int <- 1
def yo x { i <- i plus x; this }
def j { (yo < 5) i }
}
new X, j
]]));
// Method shadows global function (TODO)
/*assertEqualsVerbose(6, runScript([[
class X {
}
new X, j
]]));*/
// Auto-"this" in initializer
assertEqualsVerbose(6, runScript([[
class X {
i: int <- 5
initializer {
i <- i plus 1
}
}
new X, i
]]));
}