Skip to content
Snippets Groups Projects
Unverified Commit 3c528e0a authored by Max Woolf's avatar Max Woolf Committed by GitLab
Browse files

Merge branch 'sq/rename-codesuggestions-terminology' into 'master'

Renames CodeSuggestions namespace terminologies and updates test coverage

See merge request https://gitlab.com/gitlab-org/gitlab/-/merge_requests/168384



Merged-by: default avatarMax Woolf <mwoolf@gitlab.com>
Approved-by: default avatarNwanna Isong <nisong@gitlab.com>
Approved-by: default avatarMeir Benayoun <mbenayoun@gitlab.com>
Approved-by: default avatarMax Woolf <mwoolf@gitlab.com>
Reviewed-by: default avatarMeir Benayoun <mbenayoun@gitlab.com>
Reviewed-by: default avatarDuo Code Reviewer <duo-code-review-bot@gitlab.com>
Reviewed-by: default avatarNwanna Isong <nisong@gitlab.com>
Co-authored-by: default avatarsholaq <squadri@gitlab.com>
parents c52ca961 ec4b0f30
No related branches found
No related tags found
No related merge requests found
Showing
with 178 additions and 159 deletions
Loading
Loading
@@ -336,8 +336,8 @@
{
file_name: 'test.py',
selected_text: selected_text,
cotent_above_cursor: 'prefix',
content_below_cursor: 'suffix'
content_above_cursor: 'content_above_cursor',
content_below_cursor: 'content_below_cursor'
}
end
 
Loading
Loading
Loading
Loading
@@ -21,8 +21,8 @@
{
file_name: 'test.py',
selected_text: 'selected',
content_above_cursor: 'prefix',
content_below_cursor: 'suffix'
content_above_cursor: 'content_above_cursor',
content_below_cursor: 'content_below_cursor'
}
end
 
Loading
Loading
Loading
Loading
@@ -253,7 +253,9 @@
end
 
describe '#code_completion' do
subject(:response) { client.code_completion(content: { prefix: "any", suffix: "thing" }, **options) }
subject(:response) do
client.code_completion(content: { content_above_cursor: "any", content_below_cursor: "thing" }, **options)
end
 
it_behaves_like 'forwarding the request correctly'
 
Loading
Loading
Loading
Loading
@@ -16,14 +16,14 @@
 
describe '#payload' do
it 'returns default payload' do
messages = { prefix: 'foo', suffix: 'bar' }
messages = { content_above_cursor: 'foo', content_below_cursor: 'bar' }
 
expect(subject.payload(messages)).to eq(
{
instances: [
{
prefix: 'foo',
suffix: 'bar'
content_above_cursor: 'foo',
content_below_cursor: 'bar'
}
],
parameters: Gitlab::Llm::VertexAi::Configuration.payload_parameters(
Loading
Loading
Loading
Loading
@@ -145,8 +145,8 @@
describe 'POST /code_suggestions/completions' do
let(:access_code_suggestions) { true }
 
let(:prefix) do
<<~PREFIX
let(:content_above_cursor) do
<<~CONTENT_ABOVE_CURSOR
def add(x, y):
return x + y
 
Loading
Loading
@@ -160,7 +160,7 @@ def divide(x, y):
return x / y
 
def is_even(n: int) ->
PREFIX
CONTENT_ABOVE_CURSOR
end
 
let(:file_name) { 'test.py' }
Loading
Loading
@@ -172,7 +172,7 @@ def is_even(n: int) ->
project_id: 33191677, # not removed given we still might get it but we will not use it
current_file: {
file_name: file_name,
content_above_cursor: prefix,
content_above_cursor: content_above_cursor,
content_below_cursor: ''
},
stream: false,
Loading
Loading
@@ -210,9 +210,9 @@ def is_even(n: int) ->
"trigger_type" => "comment"
}
],
'trimmed_prefix' => "def is_even(n: int) ->\n# A " \
'trimmed_content_above_cursor' => "def is_even(n: int) ->\n# A " \
"function that outputs the first 20 fibonacci numbers\n",
'trimmed_suffix' => '',
'trimmed_content_below_cursor' => '',
'related_files' => [],
'related_snippets' => [],
'libraries' => [],
Loading
Loading
@@ -575,11 +575,11 @@ def request
 
context 'when the task is code generation' do
let(:current_user) { authorized_user }
let(:prefix) do
<<~PREFIX
let(:content_above_cursor) do
<<~CONTENT_ABOVE_CURSOR
def is_even(n: int) ->
# A function that outputs the first 20 fibonacci numbers
PREFIX
CONTENT_ABOVE_CURSOR
end
 
let(:system_prompt) do
Loading
Loading
@@ -625,7 +625,7 @@ def get_user(session):
 
</examples>
<existing_code>
#{prefix}{{cursor}}
#{content_above_cursor}{{cursor}}
</existing_code>
The existing code is provided in <existing_code></existing_code> tags.
 
Loading
Loading
@@ -670,7 +670,7 @@ def get_user(session):
prompt: prompt,
current_file: {
file_name: file_name,
content_above_cursor: prefix,
content_above_cursor: content_above_cursor,
content_below_cursor: ''
}
)
Loading
Loading
# frozen_string_literal: true
 
RSpec.shared_context 'with comment prefixes' do
# Builds a hash with items: { [array of programming languages] => [array of comment prefixes] }
RSpec.shared_context 'with comment contents_above_cursor' do
# Builds a hash with items: { [array of programming languages] => [array of comment contents_above_cursor] }
# for example:
# {
# ["Clojure", "Lisp", "Scheme"]=>[";"],
Loading
Loading
@@ -9,10 +9,10 @@
# ["VBScript"]=>["'", "REM"],
# ...
# }
# The reason is that LANGUAGE_COMMENT_FORMATS defines either simple string comment prefixes or
# regexps which match multiple prefix options. If simple string is used, we can just reuse it,
# The reason is that LANGUAGE_COMMENT_FORMATS defines either simple string comment contents_above_cursor or
# regexps which match multiple content_above_cursor options. If simple string is used, we can just reuse it,
# if regexp is used, we need to add all matching options here.
def self.single_line_comment_prefixes
def self.single_line_comment_contents_above_cursor
CodeSuggestions::ProgrammingLanguage::LANGUAGE_COMMENT_FORMATS
.transform_values { |format| Array.wrap(format[:single]) if format[:single] }
.compact
Loading
Loading
@@ -25,20 +25,21 @@ def self.languages_missing_single_line_comments
%w[OCaml]
end
 
def self.languages_with_single_line_comment_prefix
all_prefixes = single_line_comment_prefixes
def self.languages_with_single_line_comment_content_above_cursor
all_contents_above_cursor = single_line_comment_contents_above_cursor
 
CodeSuggestions::ProgrammingLanguage::SUPPORTED_LANGUAGES.keys.each_with_object([]) do |lang, tuples|
next if languages_missing_single_line_comments.include?(lang)
 
prefixes = all_prefixes.find { |langs, _| langs.include?(lang) }&.last
if prefixes.blank?
raise "#{lang} has missing single line comment prefix, if it's a simple string match, add it to " \
"LANGUAGE_COMMENT_FORMATS, if it's a regexp, add all regexp possibilities to " \
"single_line_comment_prefixes"
contents_above_cursor = all_contents_above_cursor.find { |langs, _| langs.include?(lang) }&.last
if contents_above_cursor.blank?
raise "#{lang} has missing single line comment content_above_cursor, " \
"if it's a simple string match, add it to LANGUAGE_COMMENT_FORMATS, " \
"if it's a regexp, add all regexp possibilities to " \
"single_line_comment_content_above_cursor"
end
 
prefixes.each { |prefix| tuples << [lang, prefix] }
contents_above_cursor.each { |content_above_cursor| tuples << [lang, content_above_cursor] }
end
end
end
Loading
Loading
@@ -5,7 +5,9 @@
 
let(:language_name) { 'C#' }
 
subject { described_class.new(language_name).cursor_inside_empty_function?(content, suffix) }
subject do
described_class.new(language_name).cursor_inside_empty_function?(content_above_cursor, content_below_cursor)
end
 
context 'when various variations of empty functions are used' do
where(example: [
Loading
Loading
@@ -42,8 +44,8 @@ class MathUtils
])
 
with_them do
let(:content) { example.split("<CURSOR>").first }
let(:suffix) { example.split("<CURSOR>").last }
let(:content_above_cursor) { example.split("<CURSOR>").first }
let(:content_below_cursor) { example.split("<CURSOR>").last }
 
it { is_expected.to be_truthy }
end
Loading
Loading
@@ -65,8 +67,8 @@ class MathUtils
CONTENT
end
 
let(:content) { example.split("<CURSOR>").first }
let(:suffix) { example.split("<CURSOR>").last }
let(:content_above_cursor) { example.split("<CURSOR>").first }
let(:content_below_cursor) { example.split("<CURSOR>").last }
 
it { is_expected.to be_falsey }
end
Loading
Loading
@@ -88,8 +90,8 @@ def index3(arg1):
CONTENT
end
 
let(:content) { example.split("<CURSOR>").first }
let(:suffix) { example.split("<CURSOR>").last }
let(:content_above_cursor) { example.split("<CURSOR>").first }
let(:content_below_cursor) { example.split("<CURSOR>").last }
 
it { is_expected.to be_falsey }
end
Loading
Loading
Loading
Loading
@@ -5,7 +5,9 @@
 
let(:language_name) { 'Go' }
 
subject { described_class.new(language_name).cursor_inside_empty_function?(content, suffix) }
subject do
described_class.new(language_name).cursor_inside_empty_function?(content_above_cursor, content_below_cursor)
end
 
context 'when various variations of empty functions are used' do
where(example: [
Loading
Loading
@@ -181,8 +183,8 @@
])
 
with_them do
let(:content) { example.split("<CURSOR>").first }
let(:suffix) { example.split("<CURSOR>").last }
let(:content_above_cursor) { example.split("<CURSOR>").first }
let(:content_below_cursor) { example.split("<CURSOR>").last }
 
it { is_expected.to be_truthy }
end
Loading
Loading
@@ -202,8 +204,8 @@
CONTENT
end
 
let(:content) { example.split("<CURSOR>").first }
let(:suffix) { example.split("<CURSOR>").last }
let(:content_above_cursor) { example.split("<CURSOR>").first }
let(:content_below_cursor) { example.split("<CURSOR>").last }
 
it { is_expected.to be_falsey }
end
Loading
Loading
@@ -223,8 +225,8 @@
CONTENT
end
 
let(:content) { example.split("<CURSOR>").first }
let(:suffix) { example.split("<CURSOR>").last }
let(:content_above_cursor) { example.split("<CURSOR>").first }
let(:content_below_cursor) { example.split("<CURSOR>").last }
 
it { is_expected.to be_falsey }
end
Loading
Loading
@@ -246,8 +248,8 @@ def index3(arg1):
CONTENT
end
 
let(:content) { example.split("<CURSOR>").first }
let(:suffix) { example.split("<CURSOR>").last }
let(:content_above_cursor) { example.split("<CURSOR>").first }
let(:content_below_cursor) { example.split("<CURSOR>").last }
 
it { is_expected.to be_falsey }
end
Loading
Loading
Loading
Loading
@@ -5,9 +5,11 @@
 
let(:language_name) { 'Java' }
 
subject { described_class.new(language_name).cursor_inside_empty_function?(content, suffix) }
subject do
described_class.new(language_name).cursor_inside_empty_function?(content_above_cursor, content_below_cursor)
end
 
context 'when various variatins of empty functions are used' do
context 'when various variations of empty functions are used' do
where(example: [
<<~EXAMPLE,
int calculateSum(int a, int b) {
Loading
Loading
@@ -52,8 +54,8 @@
])
 
with_them do
let(:content) { example.split("<CURSOR>").first }
let(:suffix) { example.split("<CURSOR>").last }
let(:content_above_cursor) { example.split("<CURSOR>").first }
let(:content_below_cursor) { example.split("<CURSOR>").last }
 
it { is_expected.to be_truthy }
end
Loading
Loading
@@ -74,8 +76,8 @@
CONTENT
end
 
let(:content) { example.split("<CURSOR>").first }
let(:suffix) { example.split("<CURSOR>").last }
let(:content_above_cursor) { example.split("<CURSOR>").first }
let(:content_below_cursor) { example.split("<CURSOR>").last }
 
it { is_expected.to be_falsey }
end
Loading
Loading
@@ -97,8 +99,8 @@ def index3(arg1):
CONTENT
end
 
let(:content) { example.split("<CURSOR>").first }
let(:suffix) { example.split("<CURSOR>").last }
let(:content_above_cursor) { example.split("<CURSOR>").first }
let(:content_below_cursor) { example.split("<CURSOR>").last }
 
it { is_expected.to be_falsey }
end
Loading
Loading
Loading
Loading
@@ -5,7 +5,9 @@
 
let(:language_name) { 'JavaScript' }
 
subject { described_class.new(language_name).cursor_inside_empty_function?(content, suffix) }
subject do
described_class.new(language_name).cursor_inside_empty_function?(content_above_cursor, content_below_cursor)
end
 
context 'when various variations of empty functions are used' do
where(example: [
Loading
Loading
@@ -73,8 +75,8 @@
])
 
with_them do
let(:content) { example.split("<CURSOR>").first }
let(:suffix) { example.split("<CURSOR>").last }
let(:content_above_cursor) { example.split("<CURSOR>").first }
let(:content_below_cursor) { example.split("<CURSOR>").last }
 
it { is_expected.to be_truthy }
end
Loading
Loading
@@ -96,8 +98,8 @@
CONTENT
end
 
let(:content) { example.split("<CURSOR>").first }
let(:suffix) { example.split("<CURSOR>").last }
let(:content_above_cursor) { example.split("<CURSOR>").first }
let(:content_below_cursor) { example.split("<CURSOR>").last }
 
it { is_expected.to be_falsey }
end
Loading
Loading
@@ -113,8 +115,8 @@
CONTENT
end
 
let(:content) { example.split("<CURSOR>").first }
let(:suffix) { example.split("<CURSOR>").last }
let(:content_above_cursor) { example.split("<CURSOR>").first }
let(:content_below_cursor) { example.split("<CURSOR>").last }
 
it { is_expected.to be_falsey }
end
Loading
Loading
@@ -136,8 +138,8 @@ def index3(arg1):
CONTENT
end
 
let(:content) { example.split("<CURSOR>").first }
let(:suffix) { example.split("<CURSOR>").last }
let(:content_above_cursor) { example.split("<CURSOR>").first }
let(:content_below_cursor) { example.split("<CURSOR>").last }
 
it { is_expected.to be_falsey }
end
Loading
Loading
Loading
Loading
@@ -5,7 +5,9 @@
 
let(:language_name) { 'PHP' }
 
subject { described_class.new(language_name).cursor_inside_empty_function?(content, suffix) }
subject do
described_class.new(language_name).cursor_inside_empty_function?(content_above_cursor, content_below_cursor)
end
 
context 'when various variations of empty functions are used' do
where(example: [
Loading
Loading
@@ -73,8 +75,8 @@ class MathUtils {
])
 
with_them do
let(:content) { example.split("<CURSOR>").first }
let(:suffix) { example.split("<CURSOR>").last }
let(:content_above_cursor) { example.split("<CURSOR>").first }
let(:content_below_cursor) { example.split("<CURSOR>").last }
 
it { is_expected.to be_truthy }
end
Loading
Loading
@@ -95,8 +97,8 @@ class MathUtils {
CONTENT
end
 
let(:content) { example.split("<CURSOR>").first }
let(:suffix) { example.split("<CURSOR>").last }
let(:content_above_cursor) { example.split("<CURSOR>").first }
let(:content_below_cursor) { example.split("<CURSOR>").last }
 
it { is_expected.to be_falsey }
end
Loading
Loading
@@ -118,8 +120,8 @@ def index3(arg1):
CONTENT
end
 
let(:content) { example.split("<CURSOR>").first }
let(:suffix) { example.split("<CURSOR>").last }
let(:content_above_cursor) { example.split("<CURSOR>").first }
let(:content_below_cursor) { example.split("<CURSOR>").last }
 
it { is_expected.to be_falsey }
end
Loading
Loading
Loading
Loading
@@ -3,68 +3,70 @@
RSpec.shared_examples 'python language' do
let(:language_name) { 'Python' }
 
subject { described_class.new(language_name).cursor_inside_empty_function?(content, suffix) }
subject do
described_class.new(language_name).cursor_inside_empty_function?(content_above_cursor, content_below_cursor)
end
 
context 'when the cursor is at the end of the file' do
let(:content) do
<<~CONTENT
let(:content_above_cursor) do
<<~CONTENT_ABOVE_CURSOR
def func1():
return 0
 
def index(arg1, arg2):
 
CONTENT
CONTENT_ABOVE_CURSOR
end
 
let(:suffix) { '' }
let(:content_below_cursor) { '' }
 
it { is_expected.to be_truthy }
end
 
context 'when cursor is inside an empty method but middle of the file' do
let(:content) do
<<~CONTENT
let(:content_above_cursor) do
<<~CONTENT_ABOVE_CURSOR
def func1():
 
CONTENT
CONTENT_ABOVE_CURSOR
end
 
let(:suffix) do
<<~SUFFIX
let(:content_below_cursor) do
<<~CONTENT_BELOW_CURSOR
def index2():
return 0
 
def index3(arg1):
return 1
SUFFIX
CONTENT_BELOW_CURSOR
end
 
it { is_expected.to be_truthy }
end
 
context 'when cursor in inside a non-empty method' do
let(:content) do
<<~CONTENT
let(:content_above_cursor) do
<<~CONTENT_ABOVE_CURSOR
def func1():
 
CONTENT
CONTENT_ABOVE_CURSOR
end
 
let(:suffix) do
<<~SUFFIX
let(:content_below_cursor) do
<<~CONTENT_BELOW_CURSOR
return 0
 
def index2():
return 'something'
SUFFIX
CONTENT_BELOW_CURSOR
end
 
it { is_expected.to be_falsey }
end
 
context 'when cursor inside class method' do
let(:content) do
<<~CONTENT
let(:content_above_cursor) do
<<~CONTENT_ABOVE_CURSOR
class User(Base):
def __init__(self, f_name, l_name):
self.f_name = f_name
Loading
Loading
@@ -72,75 +74,75 @@ def __init__(self, f_name, l_name):
 
def full_name(self):
 
CONTENT
CONTENT_ABOVE_CURSOR
end
 
let(:suffix) { '' }
let(:content_below_cursor) { '' }
 
it { is_expected.to be_truthy }
end
 
context 'when cursor inside the method with multiple spaces' do
let(:content) do
<<~CONTENT
let(:content_above_cursor) do
<<~CONTENT_ABOVE_CURSOR
def func1():
 
 
 
CONTENT
CONTENT_ABOVE_CURSOR
end
 
let(:suffix) do
<<~SUFFIX
let(:content_below_cursor) do
<<~CONTENT_BELOW_CURSOR
def index2():
return 0
 
def index3(arg1):
return 1
SUFFIX
CONTENT_BELOW_CURSOR
end
 
it { is_expected.to be_truthy }
end
 
context 'when cursor is inside an empty method with comments' do
let(:content) do
<<~CONTENT
let(:content_above_cursor) do
<<~CONTENT_ABOVE_CURSOR
def index4(arg1, arg2):
return 1
 
def func1():
 
CONTENT
CONTENT_ABOVE_CURSOR
end
 
let(:suffix) do
<<~SUFFIX
let(:content_below_cursor) do
<<~CONTENT_BELOW_CURSOR
def index2():
return 0
 
def index3(arg1):
return 1
SUFFIX
CONTENT_BELOW_CURSOR
end
 
it { is_expected.to be_truthy }
end
 
context 'when language in different that the given' do
let(:content) do
<<~CONTENT
let(:content_above_cursor) do
<<~CONTENT_ABOVE_CURSOR
def index4(arg1, arg2)
return 1
end
 
def func1
 
CONTENT
CONTENT_ABOVE_CURSOR
end
 
let(:suffix) do
<<~SUFFIX
let(:content_below_cursor) do
<<~CONTENT_BELOW_CURSOR
def index2
return 0
end
Loading
Loading
@@ -148,7 +150,7 @@ def index2
def index3(arg1)
return 1
end
SUFFIX
CONTENT_BELOW_CURSOR
end
 
it { is_expected.to be_falsey }
Loading
Loading
Loading
Loading
@@ -3,35 +3,37 @@
RSpec.shared_examples 'ruby language' do
let(:language_name) { 'Ruby' }
 
subject { described_class.new(language_name).cursor_inside_empty_function?(content, suffix) }
subject do
described_class.new(language_name).cursor_inside_empty_function?(content_above_cursor, content_below_cursor)
end
 
context 'when the cursor is at the end of the file' do
let(:content) do
<<~CONTENT
let(:content_above_cursor) do
<<~CONTENT_ABOVE_CURSOR
def func1
return 0
end
 
def index(arg1, arg2)
 
CONTENT
CONTENT_ABOVE_CURSOR
end
 
let(:suffix) { '' }
let(:content_below_cursor) { '' }
 
it { is_expected.to be_truthy }
end
 
context 'when cursor is inside an empty method but middle of the file' do
let(:content) do
<<~CONTENT
let(:content_above_cursor) do
<<~CONTENT_ABOVE_CURSOR
def func1
 
CONTENT
CONTENT_ABOVE_CURSOR
end
 
let(:suffix) do
<<~SUFFIX
let(:content_below_cursor) do
<<~CONTENT_BELOW_CURSOR
def index2
return 0
end
Loading
Loading
@@ -39,37 +41,37 @@ def index2
def index3(arg1)
return 1
end
SUFFIX
CONTENT_BELOW_CURSOR
end
 
it { is_expected.to be_truthy }
end
 
context 'when cursor in inside a non-empty method' do
let(:content) do
<<~CONTENT
let(:content_above_cursor) do
<<~CONTENT_ABOVE_CURSOR
def func1
 
CONTENT
CONTENT_ABOVE_CURSOR
end
 
let(:suffix) do
<<~SUFFIX
let(:content_below_cursor) do
<<~CONTENT_BELOW_CURSOR
return 0
end
 
def index2
return 'something'
end
SUFFIX
CONTENT_BELOW_CURSOR
end
 
it { is_expected.to be_falsey }
end
 
context 'when cursor inside class method' do
let(:content) do
<<~CONTENT
let(:content_above_cursor) do
<<~CONTENT_ABOVE_CURSOR
class User
def initialize(f_name, l_name)
@f_name = f_name
Loading
Loading
@@ -78,26 +80,26 @@ def initialize(f_name, l_name)
 
def full_name
 
CONTENT
CONTENT_ABOVE_CURSOR
end
 
let(:suffix) { '' }
let(:content_below_cursor) { '' }
 
it { is_expected.to be_truthy }
end
 
context 'when cursor inside the method with multiple spaces' do
let(:content) do
<<~CONTENT
let(:content_above_cursor) do
<<~CONTENT_ABOVE_CURSOR
def func1
 
 
 
CONTENT
CONTENT_ABOVE_CURSOR
end
 
let(:suffix) do
<<~SUFFIX
let(:content_below_cursor) do
<<~CONTENT_BELOW_CURSOR
def index2
return 0
end
Loading
Loading
@@ -105,26 +107,26 @@ def index2
def index3(arg1)
return 1
end
SUFFIX
CONTENT_BELOW_CURSOR
end
 
it { is_expected.to be_truthy }
end
 
context 'when cursor is inside an empty method with comments with end keyword' do
let(:content) do
<<~CONTENT
let(:content_above_cursor) do
<<~CONTENT_ABOVE_CURSOR
def index4(arg1, arg2)
return 1
end
 
def func1
 
CONTENT
CONTENT_ABOVE_CURSOR
end
 
let(:suffix) do
<<~SUFFIX
let(:content_below_cursor) do
<<~CONTENT_BELOW_CURSOR
end
 
def index2
Loading
Loading
@@ -134,32 +136,32 @@ def index2
def index3(arg1)
return 1
end
SUFFIX
CONTENT_BELOW_CURSOR
end
 
it { is_expected.to be_truthy }
end
 
context 'when language in different that the given' do
let(:content) do
<<~CONTENT
let(:content_above_cursor) do
<<~CONTENT_ABOVE_CURSOR
def index4(arg1, arg2):
return 1
 
def func1():
 
CONTENT
CONTENT_ABOVE_CURSOR
end
 
let(:suffix) do
<<~SUFFIX
let(:content_below_cursor) do
<<~CONTENT_BELOW_CURSOR
def index2():
return 0
 
def index3(arg1):
return 1
 
SUFFIX
CONTENT_BELOW_CURSOR
end
 
it { is_expected.to be_falsey }
Loading
Loading
Loading
Loading
@@ -5,7 +5,9 @@
 
let(:language_name) { 'TypeScript' }
 
subject { described_class.new(language_name).cursor_inside_empty_function?(content, suffix) }
subject do
described_class.new(language_name).cursor_inside_empty_function?(content_above_cursor, content_below_cursor)
end
 
context 'when various variations of empty functions are used' do
where(example: [
Loading
Loading
@@ -84,8 +86,8 @@
])
 
with_them do
let(:content) { example.split("<CURSOR>").first }
let(:suffix) { example.split("<CURSOR>").last }
let(:content_above_cursor) { example.split("<CURSOR>").first }
let(:content_below_cursor) { example.split("<CURSOR>").last }
 
it { is_expected.to be_truthy }
end
Loading
Loading
@@ -106,8 +108,8 @@
CONTENT
end
 
let(:content) { example.split("<CURSOR>").first }
let(:suffix) { example.split("<CURSOR>").last }
let(:content_above_cursor) { example.split("<CURSOR>").first }
let(:content_below_cursor) { example.split("<CURSOR>").last }
 
it { is_expected.to be_falsey }
end
Loading
Loading
@@ -129,8 +131,8 @@ def index3(arg1):
CONTENT
end
 
let(:content) { example.split("<CURSOR>").first }
let(:suffix) { example.split("<CURSOR>").last }
let(:content_above_cursor) { example.split("<CURSOR>").first }
let(:content_below_cursor) { example.split("<CURSOR>").last }
 
it { is_expected.to be_falsey }
end
Loading
Loading
Loading
Loading
@@ -25,8 +25,8 @@
{
file_name: 'test.py',
selected_text: 'code selection',
cotent_above_cursor: 'prefix',
content_below_cursor: 'suffix'
cotent_above_cursor: 'content_above_cursor',
content_below_cursor: 'content_below_cursor'
}
end
 
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment