### Question:
StackTraceHelper { public static StackFrame[] convertJsStackTrace(@Nullable ReadableArray stack) { int size = stack != null ? stack.size() : 0; StackFrame[] result = new StackFrame[size]; for (int i = 0; i < size; i++) { ReadableType type = stack.getType(i); if (type == ReadableType.Map) { ReadableMap frame = stack.getMap(i); String methodName = frame.getString("methodName"); String fileName = frame.getString("file"); int lineNumber = -1; if (frame.hasKey(LINE_NUMBER_KEY) && !frame.isNull(LINE_NUMBER_KEY)) { lineNumber = frame.getInt(LINE_NUMBER_KEY); } int columnNumber = -1; if (frame.hasKey(COLUMN_KEY) && !frame.isNull(COLUMN_KEY)) { columnNumber = frame.getInt(COLUMN_KEY); } result[i] = new StackFrameImpl(fileName, methodName, lineNumber, columnNumber); } else if (type == ReadableType.String) { result[i] = new StackFrameImpl(null, stack.getString(i), -1, -1); } } return result; }  static StackFrame[] convertJsStackTrace(@Nullable ReadableArray stack); static StackFrame[] convertJsStackTrace(JSONArray stack); static StackFrame[] convertJsStackTrace(String stack); static StackFrame[] convertJavaStackTrace(Throwable exception); static String formatFrameSource(StackFrame frame); static String formatStackTrace(String title, StackFrame[] stack); static final java.lang.String COLUMN_KEY; static final java.lang.String LINE_NUMBER_KEY; }### Answer:
@Test public void testParseStackFrameWithMethod() { final StackFrame frame = StackTraceHelper.convertJsStackTrace( "render@Test.bundle:1:2000")[0]; assertThat(frame.getMethod()).isEqualTo("render"); assertThat(frame.getFileName()).isEqualTo("Test.bundle"); assertThat(frame.getLine()).isEqualTo(1); assertThat(frame.getColumn()).isEqualTo(2000); }
@Test public void testParseStackFrameWithoutMethod() { final StackFrame frame = StackTraceHelper.convertJsStackTrace( "Test.bundle:1:2000")[0]; assertThat(frame.getMethod()).isEqualTo("(unknown)"); assertThat(frame.getFileName()).isEqualTo("Test.bundle"); assertThat(frame.getLine()).isEqualTo(1); assertThat(frame.getColumn()).isEqualTo(2000); }
@Test public void testParseStackFrameWithInvalidFrame() { final StackFrame frame = StackTraceHelper.convertJsStackTrace("Test.bundle:ten:twenty")[0]; assertThat(frame.getMethod()).isEqualTo("Test.bundle:ten:twenty"); assertThat(frame.getFileName()).isEqualTo(""); assertThat(frame.getLine()).isEqualTo(-1); assertThat(frame.getColumn()).isEqualTo(-1); }
@Test public void testParseStackFrameWithNativeCodeFrame() { final StackFrame frame = StackTraceHelper.convertJsStackTrace("forEach@[native code]")[0]; assertThat(frame.getMethod()).isEqualTo("forEach@[native code]"); assertThat(frame.getFileName()).isEqualTo(""); assertThat(frame.getLine()).isEqualTo(-1); assertThat(frame.getColumn()).isEqualTo(-1); }
@Test public void testParseAlternateFormatStackFrameWithMethod() { final StackFrame frame = StackTraceHelper.convertJsStackTrace( "at func1 (/path/to/file.js:2:18)")[0]; assertThat(frame.getMethod()).isEqualTo("func1"); assertThat(frame.getFileName()).isEqualTo("file.js"); assertThat(frame.getLine()).isEqualTo(2); assertThat(frame.getColumn()).isEqualTo(18); }