<commit_before><commit_msg>added a test for StackTrace.toString()<commit_after>/*
 * Copyright (c) 2011, 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 The current stack trace is an object whose toString() method 
 * produces a string that is a record of exactly those function activations 
 * within the current isolate that had not completed execution at the point 
 * where the current exception was thrown.
 * @description Checks that the string representation of the current stack trace indeed 
 * contains the names of functions whose execution was aborted by the current exception 
 * and they're mentioned in the specified order (assuming it's innermost first).
 * @author rodionov
 */

function1() {
  () {throw "hey you!";}();
}

typedef funken();

class S {
  void function2(funken f) {
    f();
  }
}
 
class C extends S {
  static function3() {
    new C().function2(function1);
  }
}

main() {
  function4() {
    C.function3();
  }
  
  try {
    function4();
  } catch (var ex, var trace) {
    String traceStr = trace.toString();
    int idx1 = traceStr.indexOf("function1"), 
      idx2 = traceStr.indexOf("function2"), 
      idx3 = traceStr.indexOf("function3"),
      idx4 = traceStr.indexOf("function4"),
      idx5 = traceStr.indexOf("main");
    
    Expect.isTrue(idx1 >= 0);
    Expect.isTrue(idx2 > 0);
    Expect.isTrue(idx3 > 0);
    Expect.isTrue(idx4 > 0);
    Expect.isTrue(idx5 > 0);
    Expect.isTrue(idx1 < idx2);
    Expect.isTrue(idx2 < idx3);
    Expect.isTrue(idx3 < idx4);
    Expect.isTrue(idx4 < idx5);
  }
}
{'fraction_non_alphanumeric': 0.11350407450523865, 'fraction_numerical': 0.02270081490104773, 'mean_word_length': 3.319095477386935, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '927840', 'n_tokens_mistral': 540, 'n_tokens_neox': 514, 'n_words': 182}