dart-sdk/tests/corelib/regexp/regexp_regression_39406_test.dart
Lasse Reichstein Holst Nielsen 9e10ef4458 Fix null-read in RegExpMatch.groupNames.
Fixes VM, DDC and Dart2js.

BUG= http://dartbug.com/39406

Change-Id: If181eaf50905c571614b656a232564e394e1b35d
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/136635
Commit-Queue: Lasse R.H. Nielsen <lrn@google.com>
Reviewed-by: Lasse R.H. Nielsen <lrn@google.com>
Reviewed-by: Teagan Strickland <sstrickl@google.com>
Reviewed-by: Bob Nystrom <rnystrom@google.com>
2020-03-11 14:21:39 +00:00

18 lines
592 B
Dart

// Copyright (c) 2020, 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.
import "package:expect/expect.dart";
// See http://dartbug.com/39406
//
// The following code must not throw.
void main() {
var regExp = RegExp(r'\w+');
var message = 'Hello world!';
var match = regExp.firstMatch(message);
var groupNames = match!.groupNames.toList();
Expect.listEquals([], groupNames);
Expect.throwsArgumentError(() => match.namedGroup("x"));
}