| /* |
| * 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 main() (a top level |
| * function) 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; |
| } |
| |
| main() { |
| dynamic x = new Object(); |
| Expect.throws(() {x.v = e();}, (e) => e is NoSuchMethodError); |
| Expect.isTrue(evaluated); |
| } |