blob: 2216e53d48ab2817efa0b6e311a7bf2d8f582018 [file] [log] [blame]
// Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
/**
* @assertion Evaluation of an assignment a of the form v = e proceeds as
* follows:
* Let d be the innermost declaration whose name is v or v =, if it exists.
* If d is the declaration of a local variable, ...
* If d is the declaration of a library variable, top level getter or top level
* setter, ...
* Otherwise, if d is the declaration of a static variable, static getter or
* static setter in class C, ...
* Otherwise, If a occurs inside a top level or static function (be it function,
* method, getter, or setter) or variable initializer, evaluation of a causes e
* to be evaluated, after which a NoSuchMethodError is thrown.
* @description Checks that if an assignment a is inside a top level setter
* then evaluation of a causes e to be evaluated, after which
* a NoSuchMethodError is thrown.
* @author sgrekhov@unipro.ru
*/
import '../../../Utils/expect.dart';
bool evaluated = false;
int e() {
evaluated = true;
return 0;
}
set f(var val) {
dynamic x = new Object();
Expect.throws(() {x.v = e();}, (e) => e is NoSuchMethodError);
}
main() {
f = 0;
Expect.isTrue(evaluated);
}