LCOV - code coverage report
Current view: top level - test_api-0.4.8/lib/src/expect - never_called.dart (source / functions) Hit Total Coverage
Test: lcov.info Lines: 0 13 0.0 %
Date: 2021-11-28 14:37:50 Functions: 0 0 -

          Line data    Source code
       1             : // Copyright (c) 2017, the Dart project authors.  Please see the AUTHORS file
       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.
       4             : 
       5             : import 'dart:async';
       6             : 
       7             : import 'package:stack_trace/stack_trace.dart';
       8             : import 'package:test_api/hooks.dart';
       9             : 
      10             : import 'expect.dart';
      11             : import 'future_matchers.dart';
      12             : import 'util/placeholder.dart';
      13             : import 'util/pretty_print.dart';
      14             : 
      15             : /// Returns a function that causes the test to fail if it's called.
      16             : ///
      17             : /// This can safely be passed in place of any callback that takes ten or fewer
      18             : /// positional parameters. For example:
      19             : ///
      20             : /// ```
      21             : /// // Asserts that the stream never emits an event.
      22             : /// stream.listen(neverCalled);
      23             : /// ```
      24             : ///
      25             : /// This also ensures that the test doesn't complete until a call to
      26             : /// [pumpEventQueue] finishes, so that the callback has a chance to be called.
      27           0 : Null Function(
      28             :     [Object?,
      29             :     Object?,
      30             :     Object?,
      31             :     Object?,
      32             :     Object?,
      33             :     Object?,
      34             :     Object?,
      35             :     Object?,
      36             :     Object?,
      37             :     Object?]) get neverCalled {
      38             :   // Make sure the test stays alive long enough to call the function if it's
      39             :   // going to.
      40           0 :   expect(pumpEventQueue(), completes);
      41             : 
      42           0 :   var zone = Zone.current;
      43           0 :   return (
      44             :       [a1 = placeholder,
      45             :       a2 = placeholder,
      46             :       a3 = placeholder,
      47             :       a4 = placeholder,
      48             :       a5 = placeholder,
      49             :       a6 = placeholder,
      50             :       a7 = placeholder,
      51             :       a8 = placeholder,
      52             :       a9 = placeholder,
      53             :       a10 = placeholder]) {
      54           0 :     var arguments = [a1, a2, a3, a4, a5, a6, a7, a8, a9, a10]
      55           0 :         .where((argument) => argument != placeholder)
      56           0 :         .toList();
      57             : 
      58           0 :     zone.handleUncaughtError(
      59           0 :         TestFailure(
      60           0 :             'Callback should never have been called, but it was called with' +
      61           0 :                 (arguments.isEmpty
      62             :                     ? ' no arguments.'
      63           0 :                     : ':\n${bullet(arguments.map(prettyPrint))}')),
      64           0 :         zone.run(() => Chain.current()));
      65             :     return null;
      66             :   };
      67             : }

Generated by: LCOV version 1.14