Skip to content

Instantly share code, notes, and snippets.

@boffbowsh
Created November 21, 2009 21:59
Show Gist options
  • Save boffbowsh/240301 to your computer and use it in GitHub Desktop.
Save boffbowsh/240301 to your computer and use it in GitHub Desktop.
/Users/boffbowsh/code/ruby/rubinius/spec/frozen/core/kernel/require_spec.rb
Kernel#require
- is a private method
- resolves paths relative to the current working directory
- does not expand/resolve qualified files against $LOAD_PATH
- loads a .rb from an absolute path
- collapses consecutive path separators
- loads an unqualified .rb by looking in $LOAD_PATH and returning true
- allows unqualified files to contain path information (just not in the beginning)
- loads a file with ./filename even if . is not in path
- stores a non-extensioned file with its located suffix
- appends a file with no extension with .rb/.<ext> in that order to locate file
- prefers to use .rb over .<ext> if given non-extensioned file and both exist
- will load file.rb when given 'file' if it exists even if file.<ext> is loaded
- will not load file.<ext> when given 'file' if file.rb already loaded
- appends any non-ruby extensioned file with .rb/.<ext> in that order to locate file
- loads extension files
- will load explicit file.<ext> even if file.rb already loaded and vice versa
- stores the loaded file in $LOADED_FEATURES
- will not add a bad load to LOADED_FEATURES
- uses $LOADED_FEATURES to see whether file is already loaded
- will not load a file whose path appears in $LOADED_FEATURES; it will return false
- requires arbitrarily complex files (files with large numbers of AST nodes)
- raises a LoadError if the file can't be found
- raises a LoadError if the file exists but can't be readSegmentation fault
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment