Home / Function/ test_r_code_splitter() — langchain Function Reference

test_r_code_splitter() — langchain Function Reference

Architecture documentation for the test_r_code_splitter() function in test_text_splitters.py from the langchain codebase.

Entity Profile

Dependency Diagram

graph TD
  e94c9f69_c507_648a_a1cf_b32b9ac98515["test_r_code_splitter()"]
  6d6b8ad4_1cfe_fbb0_e58e_76a50487c135["test_text_splitters.py"]
  e94c9f69_c507_648a_a1cf_b32b9ac98515 -->|defined in| 6d6b8ad4_1cfe_fbb0_e58e_76a50487c135
  style e94c9f69_c507_648a_a1cf_b32b9ac98515 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

libs/text-splitters/tests/unit_tests/test_text_splitters.py lines 1118–1144

def test_r_code_splitter() -> None:
    splitter = RecursiveCharacterTextSplitter.from_language(
        Language.R, chunk_size=CHUNK_SIZE, chunk_overlap=0
    )
    code = """
library(dplyr)

my_func <- function(x) {
    return(x + 1)
}

if (TRUE) {
    print("Hello")
}
    """
    chunks = splitter.split_text(code)
    assert chunks == [
        "library(dplyr)",
        "my_func <-",
        "function(x) {",
        "return(x +",
        "1)",
        "}",
        "if (TRUE) {",
        'print("Hello")',
        "}",
    ]

Domain

Subdomains

Frequently Asked Questions

What does test_r_code_splitter() do?
test_r_code_splitter() is a function in the langchain codebase, defined in libs/text-splitters/tests/unit_tests/test_text_splitters.py.
Where is test_r_code_splitter() defined?
test_r_code_splitter() is defined in libs/text-splitters/tests/unit_tests/test_text_splitters.py at line 1118.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free