| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 library trydart.incremental_compilation_update_test; | 5 library trydart.incremental_compilation_update_test; |
| 6 | 6 |
| 7 import 'dart:html' hide | 7 import 'dart:html' hide |
| 8 Element; | 8 Element; |
| 9 | 9 |
| 10 import 'dart:async' show | 10 import 'dart:async' show |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 const ProgramResult( | 151 const ProgramResult( |
| 152 """ | 152 """ |
| 153 class C { | 153 class C { |
| 154 m() { | 154 m() { |
| 155 print('v1'); | 155 print('v1'); |
| 156 } | 156 } |
| 157 } | 157 } |
| 158 var instance; | 158 var instance; |
| 159 main() { | 159 main() { |
| 160 if (instance == null) { | 160 if (instance == null) { |
| 161 print('instance is null'); |
| 161 instance = new C(); | 162 instance = new C(); |
| 162 } | 163 } |
| 163 instance.m(); | 164 instance.m(); |
| 164 } | 165 } |
| 165 """, | 166 """, |
| 166 const <String> ['v1']), | 167 const <String> ['instance is null', 'v1']), |
| 167 const ProgramResult( | 168 const ProgramResult( |
| 168 """ | 169 """ |
| 169 class C { | 170 class C { |
| 170 m() { | 171 m() { |
| 171 print('v2'); | 172 print('v2'); |
| 172 } | 173 } |
| 173 } | 174 } |
| 174 var instance; | 175 var instance; |
| 175 main() { | 176 main() { |
| 176 if (instance == null) { | 177 if (instance == null) { |
| 178 print('instance is null'); |
| 177 instance = new C(); | 179 instance = new C(); |
| 178 } | 180 } |
| 179 instance.m(); | 181 instance.m(); |
| 180 } | 182 } |
| 181 """, | 183 """, |
| 182 const <String> ['v2']), | 184 const <String> ['v2']), |
| 183 ], | 185 ], |
| 184 | 186 |
| 185 // Test that a stored instance tearoff changes behavior when updated. | 187 // Test that a stored instance tearoff changes behavior when updated. |
| 186 const <ProgramResult>[ | 188 const <ProgramResult>[ |
| 187 const ProgramResult( | 189 const ProgramResult( |
| 188 """ | 190 """ |
| 189 class C { | 191 class C { |
| 190 m() { | 192 m() { |
| 191 print('v1'); | 193 print('v1'); |
| 192 } | 194 } |
| 193 } | 195 } |
| 194 var closure; | 196 var closure; |
| 195 main() { | 197 main() { |
| 196 if (closure == null) { | 198 if (closure == null) { |
| 199 print('closure is null'); |
| 197 closure = new C().m; | 200 closure = new C().m; |
| 198 } | 201 } |
| 199 closure(); | 202 closure(); |
| 200 } | 203 } |
| 201 """, | 204 """, |
| 202 const <String> ['v1']), | 205 const <String> ['closure is null', 'v1']), |
| 203 const ProgramResult( | 206 const ProgramResult( |
| 204 """ | 207 """ |
| 205 class C { | 208 class C { |
| 206 m() { | 209 m() { |
| 207 print('v2'); | 210 print('v2'); |
| 208 } | 211 } |
| 209 } | 212 } |
| 210 var closure; | 213 var closure; |
| 211 main() { | 214 main() { |
| 212 if (closure == null) { | 215 if (closure == null) { |
| 216 print('closure is null'); |
| 213 closure = new C().m; | 217 closure = new C().m; |
| 214 } | 218 } |
| 215 closure(); | 219 closure(); |
| 216 } | 220 } |
| 217 """, | 221 """, |
| 218 const <String> ['v2']), | 222 const <String> ['v2']), |
| 219 ], | 223 ], |
| 220 | 224 |
| 221 // Test that deleting an instance method works. | 225 // Test that deleting an instance method works. |
| 222 const <ProgramResult>[ | 226 const <ProgramResult>[ |
| 223 const ProgramResult( | 227 const ProgramResult( |
| 224 """ | 228 """ |
| 225 class C { | 229 class C { |
| 226 m() { | 230 m() { |
| 227 print('v1'); | 231 print('v1'); |
| 228 } | 232 } |
| 229 } | 233 } |
| 230 var instance; | 234 var instance; |
| 231 main() { | 235 main() { |
| 232 if (instance == null) { | 236 if (instance == null) { |
| 237 print('instance is null'); |
| 233 instance = new C(); | 238 instance = new C(); |
| 234 } | 239 } |
| 235 try { | 240 try { |
| 236 instance.m(); | 241 instance.m(); |
| 237 } catch (e) { | 242 } catch (e) { |
| 238 print('v2'); | 243 print('threw'); |
| 239 } | 244 } |
| 240 } | 245 } |
| 241 """, | 246 """, |
| 242 const <String> ['v1']), | 247 const <String> ['instance is null', 'v1']), |
| 243 const ProgramResult( | 248 const ProgramResult( |
| 244 """ | 249 """ |
| 245 class C { | 250 class C { |
| 246 } | 251 } |
| 247 var instance; | 252 var instance; |
| 248 main() { | 253 main() { |
| 249 if (instance == null) { | 254 if (instance == null) { |
| 255 print('instance is null'); |
| 250 instance = new C(); | 256 instance = new C(); |
| 251 } | 257 } |
| 252 try { | 258 try { |
| 253 instance.m(); | 259 instance.m(); |
| 254 } catch (e) { | 260 } catch (e) { |
| 255 print('v2'); | 261 print('threw'); |
| 256 } | 262 } |
| 257 } | 263 } |
| 258 """, | 264 """, |
| 259 const <String> ['v2']), | 265 const <String> ['threw']), |
| 260 ], | 266 ], |
| 261 | 267 |
| 262 // Test that deleting an instance method works, even when accessed through | 268 // Test that deleting an instance method works, even when accessed through |
| 263 // super. | 269 // super. |
| 264 const <ProgramResult>[ | 270 const <ProgramResult>[ |
| 265 const ProgramResult( | 271 const ProgramResult( |
| 266 """ | 272 """ |
| 267 class A { | 273 class A { |
| 268 m() { | 274 m() { |
| 269 print('v2'); | 275 print('v2'); |
| 270 } | 276 } |
| 271 } | 277 } |
| 272 class B extends A { | 278 class B extends A { |
| 273 m() { | 279 m() { |
| 274 print('v1'); | 280 print('v1'); |
| 275 } | 281 } |
| 276 } | 282 } |
| 277 class C extends B { | 283 class C extends B { |
| 278 m() { | 284 m() { |
| 279 super.m(); | 285 super.m(); |
| 280 } | 286 } |
| 281 } | 287 } |
| 282 var instance; | 288 var instance; |
| 283 main() { | 289 main() { |
| 284 if (instance == null) { | 290 if (instance == null) { |
| 291 print('instance is null'); |
| 285 instance = new C(); | 292 instance = new C(); |
| 286 } | 293 } |
| 287 instance.m(); | 294 instance.m(); |
| 288 } | 295 } |
| 289 """, | 296 """, |
| 290 const <String> ['v1']), | 297 const <String> ['instance is null', 'v1']), |
| 291 const ProgramResult( | 298 const ProgramResult( |
| 292 """ | 299 """ |
| 293 class A { | 300 class A { |
| 294 m() { | 301 m() { |
| 295 print('v2'); | 302 print('v2'); |
| 296 } | 303 } |
| 297 } | 304 } |
| 298 class B extends A { | 305 class B extends A { |
| 299 } | 306 } |
| 300 class C extends B { | 307 class C extends B { |
| 301 m() { | 308 m() { |
| 302 super.m(); | 309 super.m(); |
| 303 } | 310 } |
| 304 } | 311 } |
| 305 var instance; | 312 var instance; |
| 306 main() { | 313 main() { |
| 307 if (instance == null) { | 314 if (instance == null) { |
| 315 print('instance is null'); |
| 308 instance = new C(); | 316 instance = new C(); |
| 309 } | 317 } |
| 310 instance.m(); | 318 instance.m(); |
| 311 } | 319 } |
| 312 """, | 320 """, |
| 313 const <String> ['v2']), | 321 const <String> ['v2']), |
| 314 ], | 322 ], |
| 315 | 323 |
| 316 // Test that deleting a top-level method works. | 324 // Test that deleting a top-level method works. |
| 317 const <ProgramResult>[ | 325 const <ProgramResult>[ |
| 318 const ProgramResult( | 326 const ProgramResult( |
| 319 """ | 327 """ |
| 320 toplevel() { | 328 toplevel() { |
| 321 print('v1'); | 329 print('v1'); |
| 322 } | 330 } |
| 323 class C { | 331 class C { |
| 324 m() { | 332 m() { |
| 325 try { | 333 try { |
| 326 toplevel(); | 334 toplevel(); |
| 327 } catch (e) { | 335 } catch (e) { |
| 328 print('v2'); | 336 print('threw'); |
| 329 } | 337 } |
| 330 } | 338 } |
| 331 } | 339 } |
| 332 var instance; | 340 var instance; |
| 333 main() { | 341 main() { |
| 334 if (instance == null) { | 342 if (instance == null) { |
| 343 print('instance is null'); |
| 335 instance = new C(); | 344 instance = new C(); |
| 336 } | 345 } |
| 337 instance.m(); | 346 instance.m(); |
| 338 } | 347 } |
| 339 """, | 348 """, |
| 340 const <String> ['v1']), | 349 const <String> ['instance is null', 'v1']), |
| 341 const ProgramResult( | 350 const ProgramResult( |
| 342 """ | 351 """ |
| 343 class C { | 352 class C { |
| 344 m() { | 353 m() { |
| 345 try { | 354 try { |
| 346 toplevel(); | 355 toplevel(); |
| 347 } catch (e) { | 356 } catch (e) { |
| 348 print('v2'); | 357 print('threw'); |
| 349 } | 358 } |
| 350 } | 359 } |
| 351 } | 360 } |
| 352 var instance; | 361 var instance; |
| 353 main() { | 362 main() { |
| 354 if (instance == null) { | 363 if (instance == null) { |
| 364 print('instance is null'); |
| 355 instance = new C(); | 365 instance = new C(); |
| 356 } | 366 } |
| 357 instance.m(); | 367 instance.m(); |
| 358 } | 368 } |
| 359 """, | 369 """, |
| 360 const <String> ['v2']), | 370 const <String> ['threw']), |
| 361 ], | 371 ], |
| 362 | 372 |
| 363 // Test that deleting a static method works. | 373 // Test that deleting a static method works. |
| 364 const <ProgramResult>[ | 374 const <ProgramResult>[ |
| 365 const ProgramResult( | 375 const ProgramResult( |
| 366 """ | 376 """ |
| 367 class B { | 377 class B { |
| 368 static staticMethod() { | 378 static staticMethod() { |
| 369 print('v1'); | 379 print('v1'); |
| 370 } | 380 } |
| 371 } | 381 } |
| 372 class C { | 382 class C { |
| 373 m() { | 383 m() { |
| 374 try { | 384 try { |
| 375 B.staticMethod(); | 385 B.staticMethod(); |
| 376 } catch (e) { | 386 } catch (e) { |
| 377 print('v2'); | 387 print('threw'); |
| 378 } | 388 } |
| 379 try { | 389 try { |
| 380 // Ensure that noSuchMethod support is compiled. This test is not about | 390 // Ensure that noSuchMethod support is compiled. This test is not about |
| 381 // adding new classes. | 391 // adding new classes. |
| 382 B.missingMethod(); | 392 B.missingMethod(); |
| 383 print('bad'); | 393 print('bad'); |
| 384 } catch (e) { | 394 } catch (e) { |
| 385 } | 395 } |
| 386 } | 396 } |
| 387 } | 397 } |
| 388 var instance; | 398 var instance; |
| 389 main() { | 399 main() { |
| 390 if (instance == null) { | 400 if (instance == null) { |
| 401 print('instance is null'); |
| 391 instance = new C(); | 402 instance = new C(); |
| 392 } | 403 } |
| 393 instance.m(); | 404 instance.m(); |
| 394 } | 405 } |
| 395 """, | 406 """, |
| 396 const <String> ['v1']), | 407 const <String> ['instance is null', 'v1']), |
| 397 const ProgramResult( | 408 const ProgramResult( |
| 398 """ | 409 """ |
| 399 class B { | 410 class B { |
| 400 } | 411 } |
| 401 class C { | 412 class C { |
| 402 m() { | 413 m() { |
| 403 try { | 414 try { |
| 404 B.staticMethod(); | 415 B.staticMethod(); |
| 405 } catch (e) { | 416 } catch (e) { |
| 406 print('v2'); | 417 print('threw'); |
| 407 } | 418 } |
| 408 try { | 419 try { |
| 409 // Ensure that noSuchMethod support is compiled. This test is not about | 420 // Ensure that noSuchMethod support is compiled. This test is not about |
| 410 // adding new classes. | 421 // adding new classes. |
| 411 B.missingMethod(); | 422 B.missingMethod(); |
| 412 print('bad'); | 423 print('bad'); |
| 413 } catch (e) { | 424 } catch (e) { |
| 414 } | 425 } |
| 415 } | 426 } |
| 416 } | 427 } |
| 417 var instance; | 428 var instance; |
| 418 main() { | 429 main() { |
| 419 if (instance == null) { | 430 if (instance == null) { |
| 431 print('instance is null'); |
| 420 instance = new C(); | 432 instance = new C(); |
| 421 } | 433 } |
| 422 instance.m(); | 434 instance.m(); |
| 423 } | 435 } |
| 424 """, | 436 """, |
| 425 const <String> ['v2']), | 437 const <String> ['threw']), |
| 426 ], | 438 ], |
| 427 | 439 |
| 428 // Test that a newly instantiated class is handled. | 440 // Test that a newly instantiated class is handled. |
| 429 const <ProgramResult>[ | 441 const <ProgramResult>[ |
| 430 const ProgramResult( | 442 const ProgramResult( |
| 431 """ | 443 """ |
| 432 class A { | 444 class A { |
| 433 m() { | 445 m() { |
| 434 print('Called A.m'); | 446 print('Called A.m'); |
| 435 } | 447 } |
| 436 } | 448 } |
| 437 | 449 |
| 438 class B { | 450 class B { |
| 439 m() { | 451 m() { |
| 440 print('Called B.m'); | 452 print('Called B.m'); |
| 441 } | 453 } |
| 442 } | 454 } |
| 443 | 455 |
| 444 var instance; | 456 var instance; |
| 445 main() { | 457 main() { |
| 446 if (instance == null) { | 458 if (instance == null) { |
| 459 print('instance is null'); |
| 447 instance = new A(); | 460 instance = new A(); |
| 448 // } else { | |
| 449 // instance = new B(); | |
| 450 } | 461 } |
| 451 instance.m(); | 462 instance.m(); |
| 452 } | 463 } |
| 453 """, | 464 """, |
| 454 const <String>['Called A.m']), | 465 const <String>['instance is null', 'Called A.m']), |
| 455 const ProgramResult( | 466 const ProgramResult( |
| 456 """ | 467 """ |
| 457 class A { | 468 class A { |
| 458 m() { | 469 m() { |
| 459 print('Called A.m'); | 470 print('Called A.m'); |
| 460 } | 471 } |
| 461 } | 472 } |
| 462 | 473 |
| 463 class B { | 474 class B { |
| 464 m() { | 475 m() { |
| 465 print('Called B.m'); | 476 print('Called B.m'); |
| 466 } | 477 } |
| 467 } | 478 } |
| 468 | 479 |
| 469 var instance; | 480 var instance; |
| 470 main() { | 481 main() { |
| 471 if (instance == null) { | 482 if (instance == null) { |
| 483 print('instance is null'); |
| 472 instance = new A(); | 484 instance = new A(); |
| 473 } else { | 485 } else { |
| 474 instance = new B(); | 486 instance = new B(); |
| 475 } | 487 } |
| 476 instance.m(); | 488 instance.m(); |
| 477 } | 489 } |
| 478 """, | 490 """, |
| 479 const <String>['Called B.m']), | 491 const <String>['Called B.m']), |
| 480 ], | 492 ], |
| 481 | 493 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 512 } | 524 } |
| 513 } | 525 } |
| 514 | 526 |
| 515 class B extends A { | 527 class B extends A { |
| 516 get name => 'B.m'; | 528 get name => 'B.m'; |
| 517 } | 529 } |
| 518 | 530 |
| 519 var instance; | 531 var instance; |
| 520 main() { | 532 main() { |
| 521 if (instance == null) { | 533 if (instance == null) { |
| 534 print('instance is null'); |
| 522 instance = new A(); | 535 instance = new A(); |
| 523 // } else { | |
| 524 // instance = new B(); | |
| 525 } | 536 } |
| 526 instance.m(); | 537 instance.m(); |
| 527 } | 538 } |
| 528 """, | 539 """, |
| 529 const <String>['Called A.m']), | 540 const <String>['instance is null', 'Called A.m']), |
| 530 const ProgramResult( | 541 const ProgramResult( |
| 531 r""" | 542 r""" |
| 532 class A { | 543 class A { |
| 533 get name => 'A.m'; | 544 get name => 'A.m'; |
| 534 | 545 |
| 535 m() { | 546 m() { |
| 536 print('Called $name'); | 547 print('Called $name'); |
| 537 } | 548 } |
| 538 } | 549 } |
| 539 | 550 |
| 540 class B extends A { | 551 class B extends A { |
| 541 get name => 'B.m'; | 552 get name => 'B.m'; |
| 542 } | 553 } |
| 543 | 554 |
| 544 var instance; | 555 var instance; |
| 545 main() { | 556 main() { |
| 546 if (instance == null) { | 557 if (instance == null) { |
| 558 print('instance is null'); |
| 547 instance = new A(); | 559 instance = new A(); |
| 548 } else { | 560 } else { |
| 549 instance = new B(); | 561 instance = new B(); |
| 550 } | 562 } |
| 551 instance.m(); | 563 instance.m(); |
| 552 } | 564 } |
| 553 """, | 565 """, |
| 554 const <String>['Called B.m']), | 566 const <String>['Called B.m']), |
| 555 ], | 567 ], |
| 556 | 568 |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 598 ], | 610 ], |
| 599 | 611 |
| 600 // Test that top-level functions can be added. | 612 // Test that top-level functions can be added. |
| 601 const <ProgramResult>[ | 613 const <ProgramResult>[ |
| 602 const ProgramResult( | 614 const ProgramResult( |
| 603 r""" | 615 r""" |
| 604 main() { | 616 main() { |
| 605 try { | 617 try { |
| 606 foo(); | 618 foo(); |
| 607 } catch(e) { | 619 } catch(e) { |
| 608 print('v1'); | 620 print('threw'); |
| 609 } | 621 } |
| 610 } | 622 } |
| 611 """, | 623 """, |
| 612 const <String>['v1']), | 624 const <String>['threw']), |
| 613 const ProgramResult( | 625 const ProgramResult( |
| 614 r""" | 626 r""" |
| 615 foo() { | 627 foo() { |
| 616 print('v2'); | 628 print('v2'); |
| 617 } | 629 } |
| 618 | 630 |
| 619 main() { | 631 main() { |
| 620 try { | 632 try { |
| 621 foo(); | 633 foo(); |
| 622 } catch(e) { | 634 } catch(e) { |
| 623 print('v1'); | 635 print('threw'); |
| 624 } | 636 } |
| 625 } | 637 } |
| 626 """, | 638 """, |
| 627 const <String>['v2']), | 639 const <String>['v2']), |
| 628 ], | 640 ], |
| 629 | 641 |
| 630 // Test that static methods can be added. | 642 // Test that static methods can be added. |
| 631 const <ProgramResult>[ | 643 const <ProgramResult>[ |
| 632 const ProgramResult( | 644 const ProgramResult( |
| 633 r""" | 645 r""" |
| 634 class C { | 646 class C { |
| 635 } | 647 } |
| 636 | 648 |
| 637 main() { | 649 main() { |
| 638 try { | 650 try { |
| 639 C.foo(); | 651 C.foo(); |
| 640 } catch(e) { | 652 } catch(e) { |
| 641 print('v1'); | 653 print('threw'); |
| 642 } | 654 } |
| 643 } | 655 } |
| 644 """, | 656 """, |
| 645 const <String>['v1']), | 657 const <String>['threw']), |
| 646 const ProgramResult( | 658 const ProgramResult( |
| 647 r""" | 659 r""" |
| 648 class C { | 660 class C { |
| 649 static foo() { | 661 static foo() { |
| 650 print('v2'); | 662 print('v2'); |
| 651 } | 663 } |
| 652 } | 664 } |
| 653 | 665 |
| 654 main() { | 666 main() { |
| 655 try { | 667 try { |
| 656 C.foo(); | 668 C.foo(); |
| 657 } catch(e) { | 669 } catch(e) { |
| 658 print('v1'); | 670 print('threw'); |
| 659 } | 671 } |
| 660 } | 672 } |
| 661 """, | 673 """, |
| 662 const <String>['v2']), | 674 const <String>['v2']), |
| 663 ], | 675 ], |
| 664 | 676 |
| 665 // Test that instance methods can be added. | 677 // Test that instance methods can be added. |
| 666 const <ProgramResult>[ | 678 const <ProgramResult>[ |
| 667 const ProgramResult( | 679 const ProgramResult( |
| 668 r""" | 680 r""" |
| 669 class C { | 681 class C { |
| 670 } | 682 } |
| 671 | 683 |
| 672 var instance; | 684 var instance; |
| 673 | 685 |
| 674 main() { | 686 main() { |
| 675 if (instance == null) { | 687 if (instance == null) { |
| 688 print('instance is null'); |
| 676 instance = new C(); | 689 instance = new C(); |
| 677 } | 690 } |
| 678 | 691 |
| 679 try { | 692 try { |
| 680 instance.foo(); | 693 instance.foo(); |
| 681 } catch(e) { | 694 } catch(e) { |
| 682 print('v1'); | 695 print('threw'); |
| 683 } | 696 } |
| 684 } | 697 } |
| 685 """, | 698 """, |
| 686 const <String>['v1']), | 699 const <String>['instance is null', 'threw']), |
| 687 const ProgramResult( | 700 const ProgramResult( |
| 688 r""" | 701 r""" |
| 689 class C { | 702 class C { |
| 690 foo() { | 703 foo() { |
| 691 print('v2'); | 704 print('v2'); |
| 692 } | 705 } |
| 693 } | 706 } |
| 694 | 707 |
| 695 var instance; | 708 var instance; |
| 696 | 709 |
| 697 main() { | 710 main() { |
| 698 if (instance == null) { | 711 if (instance == null) { |
| 712 print('instance is null'); |
| 699 instance = new C(); | 713 instance = new C(); |
| 700 } | 714 } |
| 701 | 715 |
| 702 try { | 716 try { |
| 703 instance.foo(); | 717 instance.foo(); |
| 704 } catch(e) { | 718 } catch(e) { |
| 705 print('v1'); | 719 print('threw'); |
| 706 } | 720 } |
| 707 } | 721 } |
| 708 """, | 722 """, |
| 709 const <String>['v2']), | 723 const <String>['v2']), |
| 710 ], | 724 ], |
| 711 | 725 |
| 712 // Test that top-level functions can have signature changed. | 726 // Test that top-level functions can have signature changed. |
| 713 const <ProgramResult>[ | 727 const <ProgramResult>[ |
| 714 const ProgramResult( | 728 const ProgramResult( |
| 715 r""" | 729 r""" |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 772 class C { | 786 class C { |
| 773 foo() { | 787 foo() { |
| 774 print('v1'); | 788 print('v1'); |
| 775 } | 789 } |
| 776 } | 790 } |
| 777 | 791 |
| 778 var instance; | 792 var instance; |
| 779 | 793 |
| 780 main() { | 794 main() { |
| 781 if (instance == null) { | 795 if (instance == null) { |
| 796 print('instance is null'); |
| 782 instance = new C(); | 797 instance = new C(); |
| 783 } | 798 } |
| 784 | 799 |
| 785 instance.foo(); | 800 instance.foo(); |
| 786 } | 801 } |
| 787 """, | 802 """, |
| 788 const <String>['v1']), | 803 const <String>['instance is null', 'v1']), |
| 789 const ProgramResult( | 804 const ProgramResult( |
| 790 r""" | 805 r""" |
| 791 class C { | 806 class C { |
| 792 void foo() { | 807 void foo() { |
| 793 print('v2'); | 808 print('v2'); |
| 794 } | 809 } |
| 795 } | 810 } |
| 796 | 811 |
| 797 var instance; | 812 var instance; |
| 798 | 813 |
| 799 main() { | 814 main() { |
| 800 if (instance == null) { | 815 if (instance == null) { |
| 816 print('instance is null'); |
| 801 instance = new C(); | 817 instance = new C(); |
| 802 } | 818 } |
| 803 | 819 |
| 804 instance.foo(); | 820 instance.foo(); |
| 805 } | 821 } |
| 806 """, | 822 """, |
| 807 const <String>['v2']), | 823 const <String>['v2']), |
| 808 ], | 824 ], |
| 809 | 825 |
| 810 // Test that adding a class is supported. | 826 // Test that adding a class is supported. |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 911 class C extends B { | 927 class C extends B { |
| 912 m() { | 928 m() { |
| 913 super.m(); | 929 super.m(); |
| 914 } | 930 } |
| 915 } | 931 } |
| 916 | 932 |
| 917 var instance; | 933 var instance; |
| 918 | 934 |
| 919 main() { | 935 main() { |
| 920 if (instance == null) { | 936 if (instance == null) { |
| 937 print('instance is null'); |
| 921 instance = new C(); | 938 instance = new C(); |
| 922 } | 939 } |
| 923 instance.m(); | 940 instance.m(); |
| 924 } | 941 } |
| 925 """, | 942 """, |
| 926 const <String>['v1']), | 943 const <String>['instance is null', 'v1']), |
| 927 const ProgramResult( | 944 const ProgramResult( |
| 928 r""" | 945 r""" |
| 929 class A { | 946 class A { |
| 930 m() { | 947 m() { |
| 931 print('v2'); | 948 print('v2'); |
| 932 } | 949 } |
| 933 } | 950 } |
| 934 class B extends A { | 951 class B extends A { |
| 935 m() { | 952 m() { |
| 936 print('v1'); | 953 print('v1'); |
| 937 } | 954 } |
| 938 } | 955 } |
| 939 class C extends A { | 956 class C extends A { |
| 940 m() { | 957 m() { |
| 941 super.m(); | 958 super.m(); |
| 942 } | 959 } |
| 943 } | 960 } |
| 944 | 961 |
| 945 var instance; | 962 var instance; |
| 946 | 963 |
| 947 main() { | 964 main() { |
| 948 if (instance == null) { | 965 if (instance == null) { |
| 966 print('instance is null'); |
| 949 instance = new C(); | 967 instance = new C(); |
| 950 } | 968 } |
| 951 instance.m(); | 969 instance.m(); |
| 952 } | 970 } |
| 953 """, | 971 """, |
| 954 const <String>['v2']), | 972 const <String>['v2']), |
| 955 ], | 973 ], |
| 956 | 974 |
| 957 // Test adding a field to a class works. | 975 // Test adding a field to a class works. |
| 958 const <ProgramResult>[ | 976 const <ProgramResult>[ |
| 959 const ProgramResult( | 977 const ProgramResult( |
| 960 r""" | 978 r""" |
| 961 class A { | 979 class A { |
| 962 } | 980 } |
| 963 | 981 |
| 964 var instance; | 982 var instance; |
| 965 | 983 |
| 966 main() { | 984 main() { |
| 967 if (instance == null) { | 985 if (instance == null) { |
| 986 print('instance is null'); |
| 968 instance = new A(); | 987 instance = new A(); |
| 969 } | 988 } |
| 970 try { | 989 try { |
| 971 instance.x = 'v2'; | 990 instance.x = 'v2'; |
| 972 } catch(e) { | 991 } catch(e) { |
| 973 print('setter threw'); | 992 print('setter threw'); |
| 974 } | 993 } |
| 975 try { | 994 try { |
| 976 print(instance.x); | 995 print(instance.x); |
| 977 } catch (e) { | 996 } catch (e) { |
| 978 print('getter threw'); | 997 print('getter threw'); |
| 979 } | 998 } |
| 980 } | 999 } |
| 981 """, | 1000 """, |
| 982 const <String>['setter threw', 'getter threw']), | 1001 const <String>['instance is null', 'setter threw', 'getter threw']), |
| 983 const ProgramResult( | 1002 const ProgramResult( |
| 984 r""" | 1003 r""" |
| 985 class A { | 1004 class A { |
| 986 var x; | 1005 var x; |
| 987 } | 1006 } |
| 988 | 1007 |
| 989 var instance; | 1008 var instance; |
| 990 | 1009 |
| 991 main() { | 1010 main() { |
| 992 if (instance == null) { | 1011 if (instance == null) { |
| 1012 print('instance is null'); |
| 993 instance = new A(); | 1013 instance = new A(); |
| 994 } | 1014 } |
| 995 try { | 1015 try { |
| 996 instance.x = 'v2'; | 1016 instance.x = 'v2'; |
| 997 } catch(e) { | 1017 } catch(e) { |
| 998 print('setter threw'); | 1018 print('setter threw'); |
| 999 } | 1019 } |
| 1000 try { | 1020 try { |
| 1001 print(instance.x); | 1021 print(instance.x); |
| 1002 } catch (e) { | 1022 } catch (e) { |
| 1003 print('getter threw'); | 1023 print('getter threw'); |
| 1004 } | 1024 } |
| 1005 } | 1025 } |
| 1006 """, | 1026 """, |
| 1007 const <String>['v2']), | 1027 const <String>['v2']), |
| 1008 ], | 1028 ], |
| 1009 | 1029 |
| 1010 // Test removing a field from a class works. | 1030 // Test removing a field from a class works. |
| 1011 // TODO(ahe): The emitter still see the field, and we need to ensure that | |
| 1012 // old names aren't used again. | |
| 1013 const <ProgramResult>[ | 1031 const <ProgramResult>[ |
| 1014 const ProgramResult( | 1032 const ProgramResult( |
| 1015 r""" | 1033 r""" |
| 1016 class A { | 1034 class A { |
| 1017 var x; | 1035 var x; |
| 1018 } | 1036 } |
| 1019 | 1037 |
| 1020 var instance; | 1038 var instance; |
| 1021 | 1039 |
| 1022 main() { | 1040 main() { |
| 1023 if (instance == null) { | 1041 if (instance == null) { |
| 1042 print('instance is null'); |
| 1024 instance = new A(); | 1043 instance = new A(); |
| 1025 } | 1044 } |
| 1026 try { | 1045 try { |
| 1027 instance.x = 'v1'; | 1046 instance.x = 'v1'; |
| 1028 } catch(e) { | 1047 } catch(e) { |
| 1029 print('setter threw'); | 1048 print('setter threw'); |
| 1030 } | 1049 } |
| 1031 try { | 1050 try { |
| 1032 print(instance.x); | 1051 print(instance.x); |
| 1033 } catch (e) { | 1052 } catch (e) { |
| 1034 print('getter threw'); | 1053 print('getter threw'); |
| 1035 } | 1054 } |
| 1036 } | 1055 } |
| 1037 """, | 1056 """, |
| 1038 const <String>['v1']), | 1057 const <String>['instance is null', 'v1']), |
| 1039 const ProgramResult( | 1058 const ProgramResult( |
| 1040 r""" | 1059 r""" |
| 1041 class A { | 1060 class A { |
| 1042 } | 1061 } |
| 1043 | 1062 |
| 1044 var instance; | 1063 var instance; |
| 1045 | 1064 |
| 1046 main() { | 1065 main() { |
| 1047 if (instance == null) { | 1066 if (instance == null) { |
| 1067 print('instance is null'); |
| 1048 instance = new A(); | 1068 instance = new A(); |
| 1049 } | 1069 } |
| 1050 try { | 1070 try { |
| 1051 instance.x = 'v1'; | 1071 instance.x = 'v1'; |
| 1052 } catch(e) { | 1072 } catch(e) { |
| 1053 print('setter threw'); | 1073 print('setter threw'); |
| 1054 } | 1074 } |
| 1055 try { | 1075 try { |
| 1056 print(instance.x); | 1076 print(instance.x); |
| 1057 } catch (e) { | 1077 } catch (e) { |
| 1058 print('getter threw'); | 1078 print('getter threw'); |
| 1059 } | 1079 } |
| 1060 } | 1080 } |
| 1061 """, | 1081 """, |
| 1062 const <String>['setter threw', 'getter threw']), | 1082 const <String>['setter threw', 'getter threw']), |
| 1063 ], | 1083 ], |
| 1084 |
| 1085 // Test that named arguments can be called. |
| 1086 // TODO(ahe): This test doesn't pass yet, see expectation below. |
| 1087 const <ProgramResult>[ |
| 1088 const ProgramResult( |
| 1089 r""" |
| 1090 class C { |
| 1091 foo({a, named: 'v1', x}) { |
| 1092 print(named); |
| 1093 } |
| 1094 } |
| 1095 |
| 1096 var instance; |
| 1097 |
| 1098 main() { |
| 1099 if (instance == null) { |
| 1100 print('instance is null'); |
| 1101 instance = new C(); |
| 1102 } |
| 1103 try { |
| 1104 instance.foo(); |
| 1105 } catch (e) { |
| 1106 // TODO(ahe): This try/catch shouldn't be necessary. |
| 1107 print('threw'); |
| 1108 } |
| 1109 } |
| 1110 """, |
| 1111 const <String>['instance is null', 'v1']), |
| 1112 const ProgramResult( |
| 1113 r""" |
| 1114 class C { |
| 1115 foo({a, named: 'v1', x}) { |
| 1116 print(named); |
| 1117 } |
| 1118 } |
| 1119 |
| 1120 var instance; |
| 1121 |
| 1122 main() { |
| 1123 if (instance == null) { |
| 1124 print('instance is null'); |
| 1125 instance = new C(); |
| 1126 } |
| 1127 try { |
| 1128 instance.foo(named: 'v2'); |
| 1129 } catch (e) { |
| 1130 // TODO(ahe): This try/catch shouldn't be necessary. |
| 1131 print('threw'); |
| 1132 } |
| 1133 } |
| 1134 """, |
| 1135 const <String>['threw']), // TODO(ahe): Expect 'v2'. |
| 1136 ], |
| 1137 |
| 1138 // Test than named arguments can be called. |
| 1139 // TODO(ahe): This test doesn't pass yet, see expectation below. |
| 1140 const <ProgramResult>[ |
| 1141 const ProgramResult( |
| 1142 r""" |
| 1143 class C { |
| 1144 foo({a, named: 'v2', x}) { |
| 1145 print(named); |
| 1146 } |
| 1147 } |
| 1148 |
| 1149 var instance; |
| 1150 |
| 1151 main() { |
| 1152 if (instance == null) { |
| 1153 print('instance is null'); |
| 1154 instance = new C(); |
| 1155 } |
| 1156 try { |
| 1157 instance.foo(named: 'v1'); |
| 1158 } catch (e) { |
| 1159 // TODO(ahe): This try/catch shouldn't be necessary. |
| 1160 print('threw'); |
| 1161 } |
| 1162 } |
| 1163 """, |
| 1164 const <String>['instance is null', 'v1']), |
| 1165 const ProgramResult( |
| 1166 r""" |
| 1167 class C { |
| 1168 foo({a, named: 'v2', x}) { |
| 1169 print(named); |
| 1170 } |
| 1171 } |
| 1172 |
| 1173 var instance; |
| 1174 |
| 1175 main() { |
| 1176 if (instance == null) { |
| 1177 print('instance is null'); |
| 1178 instance = new C(); |
| 1179 } |
| 1180 try { |
| 1181 instance.foo(); |
| 1182 } catch (e) { |
| 1183 // TODO(ahe): This try/catch shouldn't be necessary. |
| 1184 print('threw'); |
| 1185 } |
| 1186 } |
| 1187 """, |
| 1188 const <String>['threw']), |
| 1189 ], |
| 1190 |
| 1191 // Test that an instance tear-off with named parameters can be called. |
| 1192 // TODO(ahe): This test doesn't pass yet, see expectation below. |
| 1193 const <ProgramResult>[ |
| 1194 const ProgramResult( |
| 1195 r""" |
| 1196 class C { |
| 1197 foo({a, named: 'v1', x}) { |
| 1198 print(named); |
| 1199 } |
| 1200 } |
| 1201 |
| 1202 var closure; |
| 1203 |
| 1204 main() { |
| 1205 if (closure == null) { |
| 1206 print('closure is null'); |
| 1207 closure = new C().foo; |
| 1208 } |
| 1209 try { |
| 1210 closure(); |
| 1211 } catch (e) { |
| 1212 // TODO(ahe): This try/catch shouldn't be necessary. |
| 1213 print('threw'); |
| 1214 } |
| 1215 } |
| 1216 """, |
| 1217 const <String>['closure is null', 'v1']), |
| 1218 const ProgramResult( |
| 1219 r""" |
| 1220 class C { |
| 1221 foo({a, named: 'v1', x}) { |
| 1222 print(named); |
| 1223 } |
| 1224 } |
| 1225 |
| 1226 var closure; |
| 1227 |
| 1228 main() { |
| 1229 if (closure == null) { |
| 1230 print('closure is null'); |
| 1231 closure = new C().foo; |
| 1232 } |
| 1233 try { |
| 1234 closure(named: 'v2'); |
| 1235 } catch (e) { |
| 1236 // TODO(ahe): This try/catch shouldn't be necessary. |
| 1237 print('threw'); |
| 1238 } |
| 1239 } |
| 1240 """, |
| 1241 const <String>['threw']), // TODO(ahe): Expect 'v2'. |
| 1242 ], |
| 1243 |
| 1244 /* |
| 1245 // Test that a lazy static is supported. |
| 1246 // TODO(ahe): This test doesn't pass yet. |
| 1247 const <ProgramResult>[ |
| 1248 const ProgramResult( |
| 1249 r""" |
| 1250 var normal; |
| 1251 |
| 1252 foo() { |
| 1253 print(normal); |
| 1254 } |
| 1255 |
| 1256 main() { |
| 1257 if (normal == null) { |
| 1258 normal = 'v1'; |
| 1259 } else { |
| 1260 normal = ''; |
| 1261 } |
| 1262 foo(); |
| 1263 } |
| 1264 """, |
| 1265 const <String>['v1']), |
| 1266 const ProgramResult( |
| 1267 r""" |
| 1268 var normal; |
| 1269 |
| 1270 var lazy = bar(); |
| 1271 |
| 1272 foo() { |
| 1273 print(lazy); |
| 1274 } |
| 1275 |
| 1276 bar() { |
| 1277 print('v2'); |
| 1278 return 'lazy'; |
| 1279 } |
| 1280 |
| 1281 main() { |
| 1282 if (normal == null) { |
| 1283 normal = 'v1'; |
| 1284 } else { |
| 1285 normal = ''; |
| 1286 } |
| 1287 foo(); |
| 1288 } |
| 1289 """, |
| 1290 const <String>['v2', 'lazy']), |
| 1291 ], |
| 1292 */ |
| 1064 ]; | 1293 ]; |
| 1065 | 1294 |
| 1066 void main() { | 1295 void main() { |
| 1067 listener.start(); | 1296 listener.start(); |
| 1068 | 1297 |
| 1069 document.head.append(lineNumberStyle()); | 1298 document.head.append(lineNumberStyle()); |
| 1070 | 1299 |
| 1071 return asyncTest(() => Future.forEach(tests, compileAndRun)); | 1300 String query = window.location.search; |
| 1301 int skip = 0; |
| 1302 if (query != null && query.length > 1) { |
| 1303 query = query.substring(1); |
| 1304 String skipParam = Uri.splitQueryString(window.location.search)['skip']; |
| 1305 if (skipParam != null) { |
| 1306 skip = int.parse(skipParam); |
| 1307 } |
| 1308 } |
| 1309 |
| 1310 return asyncTest(() => Future.forEach(tests.skip(skip), compileAndRun)); |
| 1072 } | 1311 } |
| 1073 | 1312 |
| 1074 int testCount = 1; | 1313 int testCount = 1; |
| 1075 | 1314 |
| 1076 Future compileAndRun(List<ProgramResult> programs) { | 1315 Future compileAndRun(List<ProgramResult> programs) { |
| 1077 var status = new DivElement(); | 1316 var status = new DivElement(); |
| 1078 document.body.append(status); | 1317 document.body.append(status); |
| 1079 | 1318 |
| 1080 IFrameElement iframe = | 1319 IFrameElement iframe = |
| 1081 appendIFrame( | 1320 appendIFrame( |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1228 position: absolute; | 1467 position: absolute; |
| 1229 left: 0px; | 1468 left: 0px; |
| 1230 width: 3em; | 1469 width: 3em; |
| 1231 text-align: right; | 1470 text-align: right; |
| 1232 background-color: lightgoldenrodyellow; | 1471 background-color: lightgoldenrodyellow; |
| 1233 } | 1472 } |
| 1234 '''); | 1473 '''); |
| 1235 style.type = 'text/css'; | 1474 style.type = 'text/css'; |
| 1236 return style; | 1475 return style; |
| 1237 } | 1476 } |
| OLD | NEW |