Advertisement
robertbira

Italian Translation Report: Node.js [Part 16 - 1133 words]

Jul 30th, 2018
201
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.65 KB | None | 0 0
  1. Assert
  2. Stability: 2 - Stable
  3. The module provides a simple set of assertion tests that can be used to test invariants.
  4. A and a mode exist, while it is recommended to only use
  5. For more information about the used equality comparisons see MDN's guide on equality comparisons and sameness.
  6. Class:
  7. A subclass of that indicates the failure of an assertion.
  8. All errors thrown by the module will be instances of the class.
  9. new
  10. options
  11. If provided, the error message is going to be set to this value.
  12. The property on the error instance is going to contain this value.
  13. Internally used for the error input in case e.g. is used.
  14. Internally used to indicate what operation was used for comparison (or what assertion function triggered the error).
  15. If provided, the generated stack trace is going to remove all frames up to the provided function.
  16. A subclass of that indicates the failure of an assertion.
  17. All instances contain the built-in properties ( and ) and:
  18. Set to the actual value in case e.g., is used.
  19. Indicates if the message was auto-generated or not.
  20. This is always set to the string to indicate that the error is actually an assertion error.
  21. Set to the passed in operator value.
  22. Generate an AssertionError to compare the error message later:
  23. Verify error output:
  24. When using the, any function will use the equality used in the strict function mode.
  25. So will, for example, work the same as
  26. On top of that, error messages which involve objects produce an error diff instead of displaying both objects.
  27. That is not the case for the legacy mode.
  28. It can be accessed using:
  29. Example error diff:
  30. To deactivate the colors, use the environment variable.
  31. Stability: 0 - Deprecated: Use strict mode instead.
  32. When accessing directly instead of using the property, the will be used for any function without "strict" in its name, such as
  33. It is recommended to use the instead as the can often have surprising results.
  34. This is especially true for, where the comparison rules are lax:
  35. WARNING: This does not throw an AssertionError!
  36. An alias of
  37. Tests for deep equality between the and parameters.
  38. Primitive values are compared with the
  39. Only enumerable "own" properties are considered.
  40. The implementation does not test the of objects or enumerable own properties.
  41. For such checks, consider using instead.
  42. can have potentially surprising results.
  43. The following example does not throw an because the properties on the object are not enumerable:
  44. An exception is made for and
  45. and have their contained items compared too, as expected.
  46. "Deep" equality means that the enumerable "own" properties of child objects are evaluated also:
  47. OK, object is equal to itself
  48. values of b are different
  49. OK, objects are equal
  50. Prototypes are ignored
  51. If the values are not equal, an is thrown with a property set equal to the value of the parameter.
  52. If the parameter is undefined, a default error message is assigned.
  53. If the parameter is an instance of an then it will be thrown instead of the
  54. "Deep" equality means that the enumerable "own" properties of child objects are recursively evaluated also by the following rules.
  55. Comparison details
  56. Primitive values are compared using the, used by
  57. of objects should be the same.
  58. of objects are compared using the
  59. names and messages are always compared, even if these are not enumerable properties.
  60. Enumerable own properties are compared as well.
  61. are compared both as objects and unwrapped values.
  62. properties are compared unordered.
  63. keys and items are compared unordered.
  64. Recursion stops when both sides differ or both sides encounter a circular reference.
  65. and comparison does not rely on their values.
  66. See below for further details.
  67. This fails because
  68. The following objects don't have own properties
  69. Different
  70. OK, because of the SameValue comparison
  71. Different unwrapped numbers
  72. OK because the object and the string are identical when unwrapped.
  73. Different zeros using the
  74. OK, because it is the same symbol on both objects.
  75. Input objects not identical:
  76. OK, because it is impossible to compare the entries
  77. Fails because has a property that does not contain:
  78. If the values are not equal, an is thrown with a property set equal to the value of the parameter.
  79. Awaits the promise or, if is a function, immediately calls the function and awaits the returned promise to complete.
  80. It will then check that the promise is not rejected.
  81. If is a function and it throws an error synchronously, will return a rejected with that error.
  82. If the function does not return a promise, will return a rejected with an error.
  83. In both cases the error handler is skipped.
  84. Please note: Using is actually not useful because there is little benefit by catching a rejection and then rejecting it again.
  85. Instead, consider adding a comment next to the specific code path that should not reject and keep error messages as expressive as possible.
  86. If specified, can be a or a validation function.
  87. See for more details.
  88. Besides the async nature to await the completion behaves identically to
  89. Asserts that the function does not throw an error.
  90. Please note: Using is actually not useful because there is no benefit by catching an error and then rethrowing it.
  91. When is called, it will immediately call the function.
  92. If an error is thrown and it is the same type as that specified by the parameter, then an is thrown.
  93. If the error is of a different type, or if the parameter is undefined, the error is propagated back to the caller.
  94. The following, for instance, will throw the because there is no matching error type in the assertion:
  95. However, the following will result in an with the message
  96. If an is thrown and a value is provided for the parameter, the value of will be appended to the message:
  97. Throws: AssertionError: Got unwanted exception: Whoops
  98. Tests shallow, coercive equality between the and parameters using the
  99. Throws an with the provided error message or a default error message.
  100. Using with more than two arguments is possible but deprecated.
  101. If is falsy, the error message is set as the values of and separated by the provided
  102. If just the two and arguments are provided, will default to
  103. If is provided as third argument it will be used as the error message and the other arguments will be stored as properties on the thrown object.
  104. If is provided, all stack frames above that function will be removed from stacktrace (see).
  105. If no arguments are given, the default message will be used.
  106. In the last three cases and have no influence on the error message.
  107. Example use of for truncating the exception's stacktrace:
  108. Throws if is not or
  109. This is useful when testing the argument in callbacks.
  110. The stack trace contains all frames from the error passed to including the potential new frames for itself.
  111. Create some random error frames.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement