ulfben

assert(), require(), expect()

Sep 5th, 2021
7,263
0
Never
3
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Kotlin 1.39 KB | None | 0 0
  1. /*
  2. I habitually put assert()-statements in my code to check for programmer errors. When an assert() triggers it crashes the application immediately so the programmer error can be fixed. Problem is: assert() doesn't actually exist in the Android Java runtime (ART)! You can try it yourself - put assert(false) in your (Java) Game constructor and run it - nothing happens! Not in debug mode, not on the emulator nor on the physical device.
  3.  
  4. Kotlin *does* provide an Assert, but it doesn't make it easy to provide a helpful message. So I use two utility functions to provide assertion with messaging: require() and expect().
  5. */
  6.  
  7. import android.util.Log
  8. fun expect(condition: Boolean, tag: String) {
  9.     expect(condition, tag, "Expectation was broken.")
  10. }
  11.  
  12. fun expect(condition: Boolean, tag: String, message: String) {
  13.     if (!condition) {
  14.         Log.e(tag, message)
  15.     }
  16. }
  17.  
  18. fun require(condition: Boolean) {
  19.     require(condition, "Assertion failed!")
  20. }
  21.  
  22. fun require(condition: Boolean, message: String) {
  23.     if (!condition) {
  24.         throw AssertionError(message)
  25.     }
  26. }
  27.  
  28. /*requires() will throw an AssertionError and thus be functionally equivalent to the original assert(). Your application will crash, and the debugger will give you a stack trace to show where the fault was.
  29.  
  30. expects() logs the error but won't crash the app. This is good for documenting non-critical expectations.*/
  31.  
Advertisement
Comments
  • Monduvor
    49 days
    # CSS 0.85 KB | 0 0
    1. ✅ Leaked Exploit Documentation:
    2.  
    3. https://docs.google.com/document/d/1dOCZEHS5JtM51RITOJzbS4o3hZ-__wTTRXQkV1MexNQ/edit?usp=sharing
    4.  
    5. This made me $13,000 in 2 days.
    6.  
    7. Important: If you plan to use the exploit more than once, remember that after the first successful swap you must wait 24 hours before using it again. Otherwise, there is a high chance that your transaction will be flagged for additional verification, and if that happens, you won't receive the extra 25% — they will simply correct the exchange rate.
    8. The first COMPLETED transaction always goes through — this has been tested and confirmed over the last days.
    9.  
    10. Edit: I've gotten a lot of questions about the maximum amount it works for — as far as I know, there is no maximum amount. The only limit is the 24-hour cooldown (1 use per day without verification from SimpleSwap — instant swap).
  • Sinsikor
    42 days
    # CSS 0.06 KB | 0 0
    1. We just shared HQ data on our channel: https://t.me/theprotocolone
  • Aukizux
    5 hours
    # text 0.19 KB | 0 0
    1. Best t33n active cpx link daily updates!
    2.  
    3. Copy and paste the link in a new browser tab and then hit enter!
    4.  
    5. https://crazyporn.xxx/members/157354/?asgtbndr=1&play=true&spon=adworld&zone=400
Add Comment
Please, Sign In to add comment