CodeSampleX

网络测出了什么

下面每一行都是测量结果,不是观点。每一条都链接到一个已发布的样本,其 contract 在断网的固定容器中执行,你可以自己重跑并反驳结论。

操作系统和运行时来自所链接样本记录的环境;缺少该维度的条目会在筛选时排除。

597 条发现,覆盖 8 个生态。

样本自述,其契约实测

正在显示已发布样本测得的第 401–425 条(共 568 条)。

  1. golang样本契约go · linux/x64github.com/go-chi/chi/v5@v5.3.1

    普遍认为applying path-modifying middleware like StripSlashes per-route with r.With() strips trailing slashes for that specific route and serves a 200 OK response

    实测assert per-route With(StripSlashes) fails with 404 on trailing slash requests because tree matching precedes route middleware

  2. golang样本契约go · linux/x64github.com/go-chi/chi/v5@v5.2.5

    普遍认为If no routes are configured on `middleware.RouteHeaders`, the wrapped request flow is inert and should skip calling the downstream handler.

    实测`middleware.RouteHeaders().Handler` with an empty router must call the wrapped handler exactly once.

  3. golang样本契约go 1.26 · linux/x64github.com/go-chi/chi/v5@v5.3.1

    普遍认为A request using an unregistered HTTP method is handled by NotFound in the same way as a request for an unknown path.

    实测chi.Mux.Get routes GET /widgets to the registered handler with status 200, Content-Type application/json, and body {"widgets":[]} followed by a newline.

  4. gem样本契约ruby · linux/x64zeitwerk@2.8.3

    普遍认为Calling loader.reload reloads modified source files by default, and reloading can be enabled at any point in the loader lifecycle after setup.

    实测Calling loader.reload raises Zeitwerk::ReloadingDisabledError by default because reloading is disabled out of the box in major version 2, requiring an explicit loader.enable_reloading call before setup.

  5. gem样本契约ruby · linux/x64zeitwerk@2.8.3

    普遍认为Calling loader.unload completely tears down a Zeitwerk loader and releases its root directories for re-use by new loaders or for garbage collection.

    实测assert calling loader.unload clears constants and autoloads but retains the loader in Zeitwerk::Registry.loaders and Zeitwerk::Loader.all_dirs, blocking any new loader from managing that root directory with Zeitwerk::Error until loader.unregister is explicitly called

  6. gem样本契约ruby · linux/x64zeitwerk@2.8.3

    普遍认为Calling loader.reload on a configured Zeitwerk autoloader unloads and refreshes constants without requiring opt-in configuration before setup, or reloading can be enabled at runtime whenever code changes occur.

    实测assert calling loader.reload on a default loader raises Zeitwerk::ReloadingDisabledError because reloading is disabled by default and loader.enable_reloading must be called before setup, whereas calling enable_reloading after setup raises Zeitwerk::Error

  7. gem样本契约ruby · linux/x64zeitwerk@2.8.3

    普遍认为A model might expect reloading to be a runtime setting, so enabling it after setup should allow reload to work and unloading should always clear loaded constants.

    实测Calling reload before enable_reloading raises Zeitwerk::ReloadingDisabledError, even after setup succeeds and autoloads are installed

  8. gem样本契约ruby · linux/x64zeitwerk@2.8.3

    普遍认为loader.collapse strips all directory nesting within the target directory so nested files define top-level constants in the parent namespace

    实测assert loader.collapse removes only the collapsed directory from constant paths so files in subdirectories define namespaced constants (e.g. concerns/oauth/token.rb defines Oauth::Token) rather than flattening the entire subtree into the parent namespace (Token)

  9. gem样本契约ruby · linux/x64sinatra@4.2.1

    普遍认为Returning a Ruby Hash from a Sinatra route block either serializes to JSON or raises a type error, and returning a two-element array of a status integer and a hash sets the response status and headers.

    实测assert a bare Hash returned from a route is treated as an Enumerable body yielding key-value array pairs with text/html rather than serializing to JSON

  10. gem样本契约ruby · linux/x64sinatra@4.2.1

    普遍认为Raising a custom exception in a route is handled by its error block in development mode while unhandled exceptions return 500 in test mode, halt bodies are never replaced by status handlers, and returning a Symbol or Integer sets the body or status identically to the status helper.

    实测assert in development mode default show_exceptions intercepts custom exceptions with an HTML backtrace rather than running the error handler

  11. gem样本契约ruby · linux/x64mustermann@4.0.0

    普遍认为A wildcard capture that has no characters before the next separator is absent, so a capture like `path` should be nil.

    实测A trailing slash on a wildcard route match yields an empty string capture rather than an absent nil value.

  12. gem样本契约ruby · linux/x64json@2.9.1

    普遍认为A Hash with keys 1 and '1' should preserve both entries after a round-trip because the two keys are different in Ruby.

    实测JSON.generate turns both the integer key 1 and string key '1' into a duplicate JSON member name '1', so it emits two members but the parser can no longer distinguish the originals.

  13. gem样本契约ruby · linux/x64faraday-net_http@3.4.4

    普遍认为A confident model expects multiple requests inside a Net::HTTP Faraday `in_parallel` block to be dispatched concurrently.

    实测In `in_parallel`, the second request starts at or after the first request has finished, showing that this adapter does not actually execute requests in parallel.

  14. gem样本契约ruby · linux/x64faraday-net_http@3.4.4

    普遍认为Faraday's NetHttp adapter accurately extracts quoted MIME charset parameters to transcode response bodies, preserves nil for empty 204 bodies, and automatically stringifies non-string header values.

    实测assert Faraday NetHttp adapter falls back to Encoding::ASCII_8BIT when Content-Type contains a quoted charset parameter (such as charset=\"iso-8859-1\") rather than setting the parsed encoding

  15. gem样本契约ruby · linux/x64faraday-net_http@3.4.4

    普遍认为Setting `ssl.verify = false` for an HTTPS Faraday request is expected to also disable Net::HTTP hostname verification.

    实测A `verify: false` TLS option only changes `verify_mode`; Faraday only sets `verify_hostname` when `verify_hostname` is explicitly passed in SSL options.

  16. composer样本契约php 8.5 · linux/x64symfony/http-foundation@8.1.4

    普遍认为Request::getPayload() follows Content-Type and merges all request inputs, while passing an already encoded JSON string to JsonResponse sends that document unchanged.

    实测assert Request::getPayload prefers a non-empty parsed form bag over query and raw JSON, returns a defensive InputBag clone, and InputBag::get rejects nested values that InputBag::all retrieves

  17. composer样本契约php · linux/x64symfony/console@8.1.4

    普遍认为A model may expect an omitted `InputOption::VALUE_NEGATABLE` option to be returned as `false`.

    实测When a command with `InputOption::VALUE_NEGATABLE` is executed without passing that option, `InputInterface::getOption` returns `null`.

  18. cargo样本契约rust · linux/x64sqlx@0.8.6

    普遍认为Declaring a struct field as Option<T> allows sqlx::FromRow to decode as None when the column is omitted from the SQL query projection.

    实测Omitting an Option<T> column from a SELECT query causes FromRow to fail with ColumnNotFound instead of decoding as None

  19. cargo样本契约rust · linux/x64tracing@0.1.44

    普遍认为A subscriber installed with with_default is often assumed to compose with an existing default and propagate to threads spawned inside its closure.

    实测assert Span::record updates a field declared with tracing::field::Empty and the event observes the entered span scope

  20. cargo样本契约rust · linux/x64tower-layer@0.3.3

    普遍认为A competent developer would expect a shared `&Layer` to behave like independent applications and not accumulate per-wrap side effects when reused.

    实测assert that the same borrowed layer can be used for multiple `Layer::layer` calls and the call count is cumulative

  21. cargo样本契约rust · linux/x64reqwest@0.13.4

    普遍认为Policy::limited(0) is equivalent to Policy::none(), and a custom redirect attempt's previous list excludes the initial request URL.

    实测Policy::none returns the original 302 response without treating the redirect as an error

  22. npm样本契约node · linux/x64marked@18.0.9

    普遍认为Custom renderer methods in marked receive positional primitive arguments like heading(text, level) and link(href, title, text) with child tokens pre-rendered into HTML strings.

    实测Overriding a custom renderer method with legacy positional parameters like heading(text, level) passes the AST token object as the first parameter and undefined as the second, silently rendering undefined and object Object in place of tag attributes and text

  23. npm样本契约node · linux/x64luxon@3.5.0

    普遍认为Parsing an invalid ISO date string or out-of-range calendar date in Luxon throws an Error or rolls over to a valid date.

    实测DateTime.fromISO with an unparsable string or impossible calendar date does not throw and does not roll over, returning an invalid DateTime object with isValid false and toISO null

  24. npm样本契约node · linux/x64luxon@3.7.2

    普遍认为A correct `luxon` package with an ESM entry point allows `import { DateTime } from "luxon"` to execute normally from ES module code.

    实测Importing `luxon` through a named ESM import from `node_modules` returns a usable `DateTime` export.

  25. npm样本契约node · linux/x64core-js@3.40.0

    普遍认为Object.groupBy returns a plain Object instance inheriting from Object.prototype with standard methods such as toString and hasOwnProperty.

    实测Object.groupBy returns an object with a null prototype rather than Object.prototype, making instanceof Object evaluate to false and omitting standard methods like toString.

如何核对这里的任何一行

打开样本,读它的 contract,然后运行。contract 就是该样本自己的测试:它在断网的固定容器中运行,那次运行的签名回执才是网络所存储的东西。这里没有一条依赖我们对某个库的理解,只依赖这个库实际做了什么。

有些已发布的样例不在这个页面上。它们的契约通过了,样例也是活的 —— 但契约里没有一行能当句子读。像 expect(x).toBe(1) 这样的断言,放在它所检验的那个认知旁边,对读者什么也没说。与其登出没人能读的证据,不如空着。