<commit_before>require 'cases/helper'

class NodeForSchemaCall < GQL::Call
  def execute(a, *b, &c)
  end
end

class AstField < Struct.new(:id, :alias_id, :call, :fields)
end

class ClassWithProc < Struct.new(:proc)
end

class SchemaTest < GQL::TestCase
  test "call class parameters" do
    ast_node = AstField.new(nil, nil, nil, [
      AstField.new(:parameters, nil, nil, [
        AstField.new(:id, nil, nil, nil),
        AstField.new(:type, nil, nil, nil)
      ])
    ])

    schema_call = GQL::Schema::Call.new(ast_node, NodeForSchemaCall, {}, {})

    expected = [{ id: 'a', type: 'required' }, { id: 'b', type: 'rest' }, { id: 'c', type: 'block' }]

    assert_equal expected, schema_call.value[:parameters]
  end

  test "call proc parameters" do
    ast_node = AstField.new(nil, nil, nil, [
      AstField.new(:parameters, nil, nil, [
        AstField.new(:id, nil, nil, nil),
        AstField.new(:type, nil, nil, nil)
      ])
    ])

    schema_call = GQL::Schema::Call.new(ast_node, ClassWithProc.new(-> (a, *b, &c) { }), {}, {})

    expected = [{ id: 'a', type: 'required' }, { id: 'b', type: 'rest' }, { id: 'c', type: 'block' }]

    assert_equal expected, schema_call.value[:parameters]
  end
end

<commit_msg>add missing tests<commit_after>require 'cases/helper'

class NodeForSchemaCall < GQL::Call
  def execute(a, *b, &c)
  end
end

class AstField < Struct.new(:id, :alias_id, :call, :fields)
end

class ClassWithProc < Struct.new(:proc)
end

class SchemaTest < GQL::TestCase
  test "call class parameters" do
    ast_node = AstField.new(nil, nil, nil, [
      AstField.new(:parameters, nil, nil, [
        AstField.new(:id, nil, nil, nil),
        AstField.new(:type, nil, nil, nil)
      ])
    ])

    schema_call = GQL::Schema::Call.new(ast_node, NodeForSchemaCall, {}, {})

    expected = [{ id: 'a', type: 'required' }, { id: 'b', type: 'rest' }, { id: 'c', type: 'block' }]

    assert_equal expected, schema_call.value[:parameters]
  end

  test "call proc parameters" do
    ast_node = AstField.new(nil, nil, nil, [
      AstField.new(:parameters, nil, nil, [
        AstField.new(:id, nil, nil, nil),
        AstField.new(:type, nil, nil, nil)
      ])
    ])

    schema_call = GQL::Schema::Call.new(ast_node, ClassWithProc.new(-> (a, *b, &c) { }), {}, {})

    expected = [{ id: 'a', type: 'required' }, { id: 'b', type: 'rest' }, { id: 'c', type: 'block' }]

    assert_equal expected, schema_call.value[:parameters]
  end

  test "parameter node has a raw value" do
    ast_node = AstField.new(nil, nil, nil, [
      AstField.new(:parameters, nil, nil, nil)
    ])

    schema_call = GQL::Schema::Call.new(ast_node, ClassWithProc.new(-> (a, *b, &c) { }), {}, {})

    assert_instance_of Array, schema_call.value[:parameters]
    assert_not_empty schema_call.value[:parameters].compact
  end

  test "root node has a raw value" do
    ast_node = AstField.new(nil, nil, nil, nil)

    root = GQL::Schema::Root.new(ast_node, GQL::Node, {}, {})

    assert_equal 'GQL::Node', root.value
  end
end


{'fraction_non_alphanumeric': 0.17474447741510057, 'fraction_numerical': 0.0, 'mean_word_length': 3.3971014492753624, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 6, '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': '1175021', 'n_tokens_mistral': 1089, 'n_tokens_neox': 1075, 'n_words': 268}