// Copyright (c) HashiCorp, Inc. // SPDX-License-Identifier: BUSL-1.1 package repl import ( "strings" "testing" ) func TestExpressionEntryCouldContinue(t *testing.T) { tests := []struct { Input []string Want bool }{ { nil, false, }, { []string{ "", }, false, }, { []string{ "foo(", "", // trailing newline forces termination }, false, }, // parens { []string{ "foo()", }, false, }, { []string{ "foo(", }, true, }, { []string{ "foo(", " bar,", ")", }, false, }, // brackets { []string{ "[]", }, false, }, { []string{ "[", }, true, }, { []string{ "[", "]", }, false, }, // braces { []string{ "{}", }, false, }, { []string{ "{", }, true, }, { []string{ "{", "}", }, false, }, // quotes // HCL doesn't allow splitting quoted strings over multiple lines, so // these never cause continuation. (Use heredocs instead for that) { []string{ `""`, }, false, }, { []string{ `"`, }, false, }, { []string{ `"`, `"`, }, false, }, // heredoc templates { []string{ `<